<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: AGBOOLA JOEL OLUWAFISAYO</title>
    <description>The latest articles on DEV Community by AGBOOLA JOEL OLUWAFISAYO (@astrodev5945).</description>
    <link>https://dev.to/astrodev5945</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1245999%2F0c226f04-3f3a-461f-aa2b-431cd5c3ea97.jpeg</url>
      <title>DEV Community: AGBOOLA JOEL OLUWAFISAYO</title>
      <link>https://dev.to/astrodev5945</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/astrodev5945"/>
    <language>en</language>
    <item>
      <title>Frontend Face-Off: Svelte vs. React – Which One Will Win Your Heart?</title>
      <dc:creator>AGBOOLA JOEL OLUWAFISAYO</dc:creator>
      <pubDate>Mon, 01 Jul 2024 08:26:55 +0000</pubDate>
      <link>https://dev.to/astrodev5945/frontend-face-off-svelte-vs-react-which-one-will-win-your-heart-20oc</link>
      <guid>https://dev.to/astrodev5945/frontend-face-off-svelte-vs-react-which-one-will-win-your-heart-20oc</guid>
      <description>&lt;p&gt;If you’re diving into the world of frontend development, you’ve probably heard of React and maybe even Svelte. These two frontend technologies are like the Batman and Superman of the web world. But which one should you pick for your projects? Let’s break it down in simple, fun terms and see which one fits you best. Plus, I'll share a bit about my journey and what I’m looking forward to in the HNG Internship.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Features&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;React&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Component-Based Architecture&lt;/em&gt;: Imagine building your app like Lego blocks. Each piece is a component that you can reuse and stack together to create something amazing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Virtual DOM&lt;/em&gt;: React uses a clever trick called the Virtual DOM to update your web pages super fast, without making your browser sweat.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Rich Ecosystem&lt;/em&gt;: Think of React’s ecosystem as a giant toy store with every tool and gadget you could ever need.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;JSX Syntax&lt;/em&gt;: With JSX, you write HTML-like code inside JavaScript. It’s like combining chocolate and peanut butter – it just works!&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Svelte&lt;/strong&gt;:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;No Virtual DOM&lt;/em&gt;: Svelte skips the Virtual DOM and goes straight to updating the real DOM, making it lightning fast.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Reactive Assignments&lt;/em&gt;: State management in Svelte is as easy as pie – no extra libraries needed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Smaller Bundle Size&lt;/em&gt;: Svelte apps are lean and mean, so your pages load faster.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Ease of Learning&lt;/em&gt;: Svelte’s syntax is straightforward and friendly, perfect for those just starting out.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Performance&lt;/strong&gt;&lt;br&gt;
When it comes to speed, Svelte is like a sports car while React is more of a reliable SUV. Svelte’s direct DOM updates make it faster in many cases, but React’s Virtual DOM is not slow either. For most projects, the performance difference won’t be a deal-breaker, but if you’re building something that needs to be super snappy, Svelte might have the edge.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ease of Use&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;React&lt;/em&gt;: &lt;br&gt;
React is powerful, but it can feel like you’re building a spaceship with all the parts and tools available. You’ll need to get the hang of concepts like JSX and state management libraries, which can be a bit overwhelming at first.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Svelte&lt;/em&gt;: &lt;br&gt;
Svelte, on the other hand, is like a friendly guide through the world of frontend development. Its straightforward syntax and built-in reactivity make it easier to learn and use, especially for beginners.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Community Support and Ecosystem&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;React&lt;/em&gt;: &lt;br&gt;
React has a massive community and tons of resources. Whatever problem you run into, chances are someone has already solved it and written a blog post about it. There are endless libraries and tools at your disposal.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Svelte&lt;/em&gt;: Growing Fast&lt;br&gt;
Svelte’s community is smaller but growing rapidly. You might not find as many third-party libraries, but the ones available are high quality. The Svelte community is friendly and active, so you won’t be left hanging.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use Cases&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;When to Use React&lt;/em&gt;&lt;br&gt;
-Big Projects: React’s structure is great for managing large, complex applications.&lt;/p&gt;

&lt;p&gt;-SEO-Friendly Sites: With tools like Next.js, you can make highly optimized websites.&lt;/p&gt;

&lt;p&gt;-Cross-Platform Apps: React Native lets you build mobile apps using React, which is a huge plus.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;When to Use Svelte&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;-Small to Medium Projects: Svelte shines in projects where you want speed and simplicity.&lt;/p&gt;

&lt;p&gt;-High-Performance Needs: If your app needs to be super fast, Svelte’s your go-to.&lt;/p&gt;

&lt;p&gt;-Prototyping and Learning: Svelte’s easy syntax makes it perfect for quick prototypes and learning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My Journey and HNG Internship&lt;/strong&gt;&lt;br&gt;
I’m thrilled to be part of the HNG Internship, where I’ll be diving deeper into frontend development. The program is a fantastic opportunity to learn from the best and work on real-world projects. If you’re interested, check out the &lt;a href="https://hng.tech/internship"&gt;HNG Internship&lt;/a&gt; and see how you can get involved. They also offer &lt;a href="https://hng.tech/premium"&gt;premium services&lt;/a&gt; to help you level up your skills even further.&lt;/p&gt;

&lt;p&gt;I see ReactJS as a powerful and widely-used frontend technology with a lot of tools and resources, making it ideal for large-scale applications. However, I feel it may be overwhelming for beginners like me due to its steep learning curve and the need to understand various concepts and libraries. Despite this, I recognize its strengths and I am  looking forward to deepening my knowledge of ReactJS during the HNG Internship.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Both Svelte and React have their unique strengths. React is like a well-equipped toolbox perfect for large-scale projects, while Svelte is a sleek, fast option great for smaller projects and high-performance needs. Ultimately, the choice depends on what you’re building and your personal preference. As I continue my journey in the HNG Internship, I’m excited to explore both and see where they can take me.&lt;/p&gt;

&lt;p&gt;So, what’s your pick? Are you team React or team Svelte? Either way, you’re in for an exciting ride in the world of frontend development!&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>svelte</category>
    </item>
    <item>
      <title>Mastering the Art of Dynamic Content: A Guide to Harnessing DraftJS in React for Seamless Post Creation and Server Integration</title>
      <dc:creator>AGBOOLA JOEL OLUWAFISAYO</dc:creator>
      <pubDate>Thu, 04 Jan 2024 17:30:50 +0000</pubDate>
      <link>https://dev.to/astrodev5945/mastering-the-art-of-dynamic-content-a-guide-to-harnessing-draftjs-in-react-for-seamless-post-creation-and-server-integration-5fgh</link>
      <guid>https://dev.to/astrodev5945/mastering-the-art-of-dynamic-content-a-guide-to-harnessing-draftjs-in-react-for-seamless-post-creation-and-server-integration-5fgh</guid>
      <description>&lt;p&gt;&lt;strong&gt;WHY DRAFTJS&lt;/strong&gt; :&lt;br&gt;
DraftJS is useful for effortless rich text editing, seamless integration with React, predictable state management, and editor customization with ease. &lt;br&gt;
It also helps elevate your projects with a powerful, flexible, and developer-friendly solution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;INSTALLING RELEVANT DEPENDENCIES IN REACT&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;Ensure you have npm installed. Open your terminal and run&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install axios&lt;/code&gt;&lt;br&gt;
&lt;code&gt;npm install draft-js react-draft-wysiwyg&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;These are the main packages required for draftjs integration&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create editor component with draftjs&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from "react";
import { EditorState } from "draft-js";
import { Editor } from "react-draft-wysiwyg";

const EditorComponent = ({ editorState, setEditorState }) =&amp;gt; {
  const handleEditorChange = (newEditorState) =&amp;gt; {
    // Ensure newEditorState is an instance of EditorState
    const updatedEditorState =
      newEditorState instanceof EditorState
        ? newEditorState
        : EditorState.createEmpty(); // You might want to adjust this based on your application logic
    setEditorState(updatedEditorState);
  };
  return (
    &amp;lt;&amp;gt;
      &amp;lt;Editor
        editorState={editorState}
        onEditorStateChange={handleEditorChange}  //handles editor states change when in use
        toolbarClassName="toolbar-class"
        editorClassName="editor-class"
        wrapperClassName="wrapper-class"
      /&amp;gt;
    &amp;lt;/&amp;gt;
  );
};

export default EditorComponent;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Make use of the editor component in a post component that sends data to the server&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useState } from "react";
import { EditorState, convertToRaw } from "draft-js";
import EditorComponent from "./EditorComponent";
import axios from "axios";

const PostToServer = () =&amp;gt; {
  const [editorState, setEditorState] = useState(() =&amp;gt;
    EditorState.createEmpty()
  );
  //pass the state into the editor component to track changes in the editor
  const editorData = new FormData();

  const handlePostSubmit = async (e) =&amp;gt; {
    e.preventDefault();
    const content = JSON.stringify(
      convertToRaw(editorState.getCurrentContent())
    );

    editorData.append("editorData", content);

    try {
      // this where we make use of axios
      const response = await axios.post(
        "http://localhost:8080/post/create-post", // url for server/backend which has a field called editor data
        editorData,
        {
          headers: {
            "Content-Type": "multipart/form-data",
            // Add any additional headers as needed (e.g., authorization headers)
          },
        }
      );
      console.log(response.data.editorData);
    } catch (error) {
      console.error(error.message);
    }
  };
  return (
    &amp;lt;form onSubmit={handlePostSubmit}&amp;gt;
      &amp;lt;EditorComponent
        editorState={editorState}
        setEditorState={setEditorState}
      /&amp;gt;
      &amp;lt;button type="submit"&amp;gt;Button for storing post value on backend&amp;lt;/button&amp;gt;
    &amp;lt;/form&amp;gt;
  );
};

export default PostToServer;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Editor data being sent to server/backend should appear like this&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
content: {"blocks":&lt;br&gt;
[&lt;br&gt;
{"key":"4rh99","text":"It's very gray today. I ate cornflakes ","type":"unstyled","depth":0,"inlineStyleRanges":[],"entityRanges":[],"data":{}},&lt;br&gt;
{"key":"fdh6","text":"honey","type":"unordered-list-item","depth":0,"inlineStyleRanges":[],"entityRanges":[],"data":{}},{"key":"13aee","text":"a banana","type":"unordered-list-item","depth":0,"inlineStyleRanges":[],"entityRanges":[],"data":{}},{"key":"bb1p5","text":"and peanutbutter ","type":"unordered-list-item","depth":0,"inlineStyleRanges":[],"entityRanges":[],"data":{}},{"key":"8j2ad","text":"for breakfast. ","type":"unstyled","depth":0,"inlineStyleRanges":[],"entityRanges":[],"data":{}},{"key":"fjio6","text":"","type":"unstyled","depth":0,"inlineStyleRanges":[],"entityRanges":[],"data":{}},{"key":"eblll","text":"Valentine's day is this weekend. ","type":"unstyled","depth":0,"inlineStyleRanges":[{"offset":0,"length":16,"style":"BOLD"}],"entityRanges":[],"data":{}}],"entityMap":{}}&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;finally we create another component to get the data that has been stored on the server&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useEffect, useState } from "react";
import axios from "axios";
import { Editor, EditorState, convertFromRaw } from "draft-js";

const GetData = () =&amp;gt; {
  const [apiData, setApiData] = useState([]);
  //   state for editor data gotten from server
  useEffect(() =&amp;gt; {
    const fetchData = async () =&amp;gt; {
      try {
        const response = await axios.get("http://localhost:8080/post/get-post");
        setApiData(response.data.editorData);
        console.log("editor api Response:", response.data.editorData);
      } catch (error) {
        console.error(error.message);
      }
    };
    fetchData();
  }, []);

  return (
    &amp;lt;&amp;gt;
      {apiData.map((data) =&amp;gt; {
        const contentState = convertFromRaw(JSON.parse(data.body));
        const editorState = EditorState.createWithContent(contentState);
        return (
          &amp;lt;div&amp;gt;
            &amp;lt;Editor editorState={editorState} readOnly={true} /&amp;gt;
            {/* the readOnly value enable editor reads the data gotten from the server and display it again through draftjs */}
          &amp;lt;/div&amp;gt;
        );
      })}
    &amp;lt;/&amp;gt;
  );
};

export default GetData;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;POST&lt;/em&gt;&lt;br&gt;
Get current content from the editor state using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;JSON.stringify(convertToRaw(editorState.getCurrentContent()))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;which then convert the current state to a string .&lt;/p&gt;

&lt;p&gt;&lt;em&gt;GET&lt;/em&gt;&lt;br&gt;
Display the data in a Draft.js Editor set to readOnly.&lt;br&gt;
Fetch the post from the server and then convert it to readable content with this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const contentState = convertFromRaw(JSON.parse(data.body));
    const editorState = EditorState.createWithContent(contentState);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Show it in an Editor like so&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Editor editorState={editorState} readOnly={true}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Drop a like and share if you found this helpful.⚙👩‍💻&lt;/p&gt;

</description>
    </item>
    <item>
      <title>CREATE REACT APP WITH VITE 2024</title>
      <dc:creator>AGBOOLA JOEL OLUWAFISAYO</dc:creator>
      <pubDate>Mon, 01 Jan 2024 16:55:49 +0000</pubDate>
      <link>https://dev.to/astrodev5945/create-react-app-with-vite-2024-mi1</link>
      <guid>https://dev.to/astrodev5945/create-react-app-with-vite-2024-mi1</guid>
      <description>&lt;p&gt;Creating a React app with &lt;strong&gt;Vite&lt;/strong&gt; is a straightforward process that offers fast development and optimized builds compared to creating React app through &lt;strong&gt;CRA&lt;/strong&gt; command. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vite&lt;/strong&gt; is a build tool that focuses on speed and efficiency, making it an excellent choice for React developers. Here's a step-by-step guide to creating a React app with Vite:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;: Install &lt;em&gt;Node.js&lt;/em&gt; and &lt;em&gt;npm&lt;/em&gt;:&lt;br&gt;
Ensure you have &lt;em&gt;Node.js&lt;/em&gt; and &lt;em&gt;npm&lt;/em&gt; (Node Package Manager) installed on your machine. You can download them from &lt;em&gt;&lt;a href="https://nodejs.org/"&gt;https://nodejs.org/&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;: Install &lt;em&gt;Vite&lt;/em&gt; Globally:&lt;br&gt;
Open a terminal and install &lt;em&gt;Vite&lt;/em&gt; globally using the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install -g create-vite&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;Step 3&lt;/strong&gt;: Create a new React app:&lt;br&gt;
Create a new React app using &lt;em&gt;Vite&lt;/em&gt; by running the following command in your terminal:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm create vite@latest app-name -- --template react&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4&lt;/strong&gt;:Run &lt;code&gt;npm install&lt;/code&gt; to add missing dependencies &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5&lt;/strong&gt;: In terminal navigate to the project directory&lt;/p&gt;

&lt;p&gt;&lt;code&gt;cd app-name&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6&lt;/strong&gt;: Start the development server:&lt;br&gt;
Run the following command to start the development server:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm run dev&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will launch your React app in development mode. By default, it will be available at &lt;a href="http://localhost:3000/"&gt;http://localhost:3000/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7&lt;/strong&gt;: Explore the project structure:&lt;br&gt;
&lt;em&gt;Vite&lt;/em&gt; generates a project structure that is minimal and efficient. Key directories and files include:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;src&lt;/strong&gt;: Contains your React components and application logic.&lt;br&gt;
&lt;strong&gt;public&lt;/strong&gt;: Houses static assets that should be publicly accessible.&lt;br&gt;
index.html: The main HTML file for your app.&lt;br&gt;
&lt;strong&gt;main.js&lt;/strong&gt; or &lt;strong&gt;main.jsx&lt;/strong&gt;: The entry point for your application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 8&lt;/strong&gt;: Build the production version:&lt;br&gt;
When you're ready to deploy your app, build the production version by running:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm run build&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will create an optimized build in the dist directory.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
      <category>vite</category>
    </item>
  </channel>
</rss>
