<?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>Forem: Esther Itolima</title>
    <description>The latest articles on Forem by Esther Itolima (@esedev).</description>
    <link>https://forem.com/esedev</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%2F107609%2F74230fbe-c14a-4ef0-ba57-3d7dddf3a6a9.jpeg</url>
      <title>Forem: Esther Itolima</title>
      <link>https://forem.com/esedev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/esedev"/>
    <language>en</language>
    <item>
      <title>Available for freelance Technical Writer Gigs.</title>
      <dc:creator>Esther Itolima</dc:creator>
      <pubDate>Wed, 06 Sep 2023 13:29:25 +0000</pubDate>
      <link>https://forem.com/esedev/available-for-freelance-technical-writer-gigs-2pgp</link>
      <guid>https://forem.com/esedev/available-for-freelance-technical-writer-gigs-2pgp</guid>
      <description>&lt;p&gt;I write Technical Article on UI and Development Docs. Also make tutorials for frontend Technologies such as React.js, JavaScript, CSS, TailwindCSS.&lt;/p&gt;

&lt;p&gt;Twitter: @EstherItolima | Email: &lt;a href="mailto:itolimaesther@gmail.com"&gt;itolimaesther@gmail.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>freelance</category>
      <category>gigs</category>
      <category>writing</category>
      <category>react</category>
    </item>
    <item>
      <title>Understanding when and how to use import and export in React</title>
      <dc:creator>Esther Itolima</dc:creator>
      <pubDate>Sat, 02 Sep 2023 21:10:35 +0000</pubDate>
      <link>https://forem.com/esedev/understanding-when-and-how-to-use-import-and-export-in-react-43h9</link>
      <guid>https://forem.com/esedev/understanding-when-and-how-to-use-import-and-export-in-react-43h9</guid>
      <description>&lt;p&gt;React operates as a component-based framework, allowing you to reuse components throughout your codebase. Component reusability involves reusing components wherever necessary, made possible by using the import and export statements.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;p&gt;Before you proceed with this article, It's important you're familiar with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React&lt;/li&gt;
&lt;li&gt;JavaScript&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Understanding When to Import and Export
&lt;/h3&gt;

&lt;p&gt;It's important to understand that when you talk about importing a component, there must first be a component to export. So, let's begin by looking at what the export does.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Export&lt;/strong&gt;: Exporting is about making your component, function, or variable usable in other files.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In React, these shared parts are usually components, functions, or information that are helpful. When you export something, you say, "Hey, other parts of the code or external files can use this, too!" This is useful for keeping your code organized and making it easy to use repeatedly.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For example, if you've made a special button in your React project, like a &lt;code&gt;Button&lt;/code&gt; you can export it. Then, other parts of your project can use the same button without making a new one. It's like sharing your cool toy so everyone can play with it.&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;function Button(props) {

    const {value, id, className } = props;
    return (
      &amp;lt;button
          id={id}
          className={`${className}`}
      &amp;gt;
          {value}
      &amp;lt;/button&amp;gt;
    )
}

export default Button
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this part of the code, you create a custom React component called &lt;code&gt;Button&lt;/code&gt;. This component takes in some properties (props) you can customize when using this component in your app.&lt;/p&gt;

&lt;p&gt;You're extracting values from the props object inside the component using destructuring. These values are value, id, and className.&lt;/p&gt;

&lt;p&gt;The component returns a button element with the specified properties. This Button component is designed to render a button with the provided text (value), id, and className.&lt;/p&gt;

&lt;p&gt;Finally, you're using &lt;code&gt;export default&lt;/code&gt; to export the Button component. This means that other parts of your app can import and use this special Button component.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Import&lt;/strong&gt;: Importing, on the other hand, is about making a component, function, or variable accessible to be used in a specific file.&lt;/p&gt;

&lt;p&gt;Importing and exporting go hand in hand. Once you've shared something by exporting it, you can grab it and use it in a different part of your code by importing it. It's like borrowing a cool tool from a friend.&lt;/p&gt;

&lt;p&gt;When you import, you prevent the need to copy and paste the same thing repeatedly. That way, your code stays neat, and you don't have to worry about making mistakes.&lt;/p&gt;

&lt;p&gt;Another bonus of importing is that it helps you keep your codebase organized. Instead of having one huge pile of code, you can split it into smaller pieces. Each piece can import just what it needs, making your work much cleaner and simpler.&lt;/p&gt;

&lt;p&gt;So, importing isn't just about bringing things in; it's about keeping your program clean and avoiding mistakes.&lt;/p&gt;

&lt;p&gt;Now, let's move on to the next part of the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { ComponentA, ComponentB, ComponentC } from './Componentfiles'
import Button from './Button.'

function ComponentD() {

  return (
      &amp;lt;div&amp;gt;
        &amp;lt;ComponentA /&amp;gt;
        &amp;lt;ComponentB /&amp;gt;
        &amp;lt;ComponentC /&amp;gt;

        &amp;lt;Button
          value= "Learn More"
          id= "btnLearn"
          className="btn btn-primary" //blue button
        /&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}

export default ComponentD
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Import the custom Button component that you defined earlier inside &lt;code&gt;ComponentD&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Lastly, you're using the Button component you imported. You're passing specific properties (like value, id, and className) to customize how the button should look. These properties can differ where you're using the special Button component.&lt;/p&gt;

&lt;p&gt;For instance, you want to use the Button component in &lt;code&gt;ComponentA&lt;/code&gt; with a different text, looks, and id.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export function ComponentA() {
  return (
    &amp;lt;div&amp;gt;
      ComponentA
      &amp;lt;Button
        value= "Click A"
        id= "btnClick"
        className="btn btn-warning" //yellow button
      /&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And here is the final result.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qigH7Xtp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zue2icvlypwuiskd605v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qigH7Xtp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zue2icvlypwuiskd605v.png" alt="Button component final result" width="800" height="413"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Export and Import Components
&lt;/h3&gt;

&lt;p&gt;There are two methods for exporting a component:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Default export&lt;/li&gt;
&lt;li&gt;Named export&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each approach has its distinct way of importing, and you can decide to use either the &lt;code&gt;default export&lt;/code&gt; statement in a file or a combination of both default and &lt;code&gt;named export&lt;/code&gt; statements within a file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Default export:&lt;/strong&gt; The default export statement is automatically added to your &lt;code&gt;App.js&lt;/code&gt; file when you create a React project, usually found at the end of the code.&lt;br&gt;
The &lt;code&gt;default export&lt;/code&gt; can only be used once within a file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SPO5YgOI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a4d6ywuarpzkswp4iqrf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SPO5YgOI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a4d6ywuarpzkswp4iqrf.png" alt="default export component" width="800" height="320"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//App.js
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'

function App() {
  const [count, setCount] = useState(0)

  return (
    &amp;lt;&amp;gt;
      &amp;lt;div&amp;gt;
        &amp;lt;a href="https://vitejs.dev" target="_blank"&amp;gt;
          &amp;lt;img src={viteLogo} className="logo" alt="Vite logo"
          /&amp;gt;
        &amp;lt;/a&amp;gt;
        &amp;lt;a href="https://react.dev" target="_blank"&amp;gt;
          &amp;lt;img src={reactLogo} className="logo react" 
          alt="React logo" /&amp;gt;
        &amp;lt;/a&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;h1&amp;gt;Vite + React&amp;lt;/h1&amp;gt;
      &amp;lt;div className="card"&amp;gt;
        &amp;lt;button onClick={() =&amp;gt; setCount((count) =&amp;gt; count + 
        1)}&amp;gt;
          count is {count}
        &amp;lt;/button&amp;gt;
        &amp;lt;p&amp;gt;
          Edit &amp;lt;code&amp;gt;src/App.jsx&amp;lt;/code&amp;gt; and save to test HMR
        &amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;p className="read-the-docs"&amp;gt;
        Click on the Vite and React logos to learn more
      &amp;lt;/p&amp;gt;
    &amp;lt;/&amp;gt;
  )
}

export default App //default export statement
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your &lt;code&gt;App.js&lt;/code&gt; file might have a different appearance than the example shown above due to my use of the Vite tool for setting up the React project.&lt;/p&gt;

&lt;p&gt;For more details, refer to my previous article: &lt;a href="https://dev.to/esedev/create-react-app-vs-vite-which-one-should-you-choose-for-your-next-react-project-5268"&gt;Create React App vs Vite: Which One Should You Choose for Your Next React Project?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Create a new component and add the default export statement followed by your component name.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Like this&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;//ComponentA
function ComponentA() {
  return (
    &amp;lt;div&amp;gt;ComponentA&amp;lt;/div&amp;gt;
  )
}

export default ComponentA
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;or this&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;//ComponentA
import React from 'react'

export default function ComponentA() {
  return (
    &amp;lt;div&amp;gt;ComponentA&amp;lt;/div&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both methods will give the same outcome. The only difference lies in how they're implemented. In the first approach, after creating the function, the default export statement &lt;code&gt;export default ComponentA&lt;/code&gt; is placed at the end of the code.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;export default&lt;/code&gt; is positioned on the same line as the function in the second approach.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Importing a component with a default export&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, let's get your components talking to each other. To import a component that's been default exported, use the import keyword followed by your chosen name and the file's export path.&lt;/p&gt;

&lt;p&gt;Create a new component named ComponentB and proceed to import &lt;code&gt;ComponentA&lt;/code&gt; in &lt;code&gt;ComponentB&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Like this&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;//ComponentB
import React from 'react'
import ComponentA from './ComponentA'

function ComponentB() {
  return (
    &amp;lt;div&amp;gt;
      &amp;lt;ComponentA/&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}

export default ComponentB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; When dealing with a default export statement, you can choose any name after the &lt;code&gt;import&lt;/code&gt; keyword, while the path should point to the original file, which in this case is &lt;code&gt;ComponentA.js&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;This practice applies only when importing a default export statement component.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Like this&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;//ComponentB
import React from 'react'
import FirstComponent from './ComponentA'

function ComponentB() {
  return (
    &amp;lt;div&amp;gt;
      &amp;lt;FirstComponent/&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}

export default ComponentB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Named export:&lt;/strong&gt; The named export statement comprises the export keyword, the function keyword, and the component's name. The named export can be used in a file to export multiple components.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HZE_Z6e5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7bg796nboz3ny4sne2l8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HZE_Z6e5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7bg796nboz3ny4sne2l8.png" alt="Image description" width="800" height="157"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Like this&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Single component&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'

export function ComponentA() {
  return (
    &amp;lt;div&amp;gt;ComponentA&amp;lt;/div&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Multiple named export statement components in a file named &lt;code&gt;Componentfiles.js&lt;/code&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'

//ComponentA
export function ComponentA() {
  return (
    &amp;lt;div&amp;gt;ComponentA&amp;lt;/div&amp;gt;
  )
}

//ComponentB
export function ComponentB() {
  return (
    &amp;lt;div&amp;gt;ComponentB&amp;lt;/div&amp;gt;
  )
}

//ComponentC
export function ComponentC() {
  return (
    &amp;lt;div&amp;gt;ComponentC&amp;lt;/div&amp;gt;
  )
}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Importing a component with a named export&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To import a named component, utilize the import keyword, enclose the component name within curly braces &lt;code&gt;{}&lt;/code&gt;, and specify the path to the exported file.&lt;/p&gt;

&lt;p&gt;When importing multiple components within a file, encase all the component names within the curly braces {}. These component names within the curly braces must precisely match the names of the exported components.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Like this&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 {ComponentA, ComponentB, ComponentC} from './Componentfiles'

function ComponentD() {
  return (
      &amp;lt;div&amp;gt;
          &amp;lt;ComponentA /&amp;gt;
          &amp;lt;ComponentB /&amp;gt;
          &amp;lt;ComponentC/&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}

export default ComponentD
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;You learned about understanding import and export statements in React, and we also looked at the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When and How to import and export a component&lt;/li&gt;
&lt;li&gt;Two(2) ways to export(default export and named export) a component and&lt;/li&gt;
&lt;li&gt;Importing a component with a default export and named export statement.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Well done on finishing this article! If you have questions, I'm here to help. Connect with me on social media &lt;strong&gt;@EstherItolima&lt;/strong&gt; or email &lt;a href="//itolimaesther@gmail.com"&gt;itolimaesther@gmail.com&lt;/a&gt; for more support. Your interest matters, and I'm excited to assist you!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>frontend</category>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Exploring routing, data fetching and error handling in React Router 6.4+</title>
      <dc:creator>Esther Itolima</dc:creator>
      <pubDate>Fri, 11 Aug 2023 14:26:00 +0000</pubDate>
      <link>https://forem.com/esedev/exploring-routing-data-fetching-and-error-handling-in-react-router-64-3h1p</link>
      <guid>https://forem.com/esedev/exploring-routing-data-fetching-and-error-handling-in-react-router-64-3h1p</guid>
      <description>&lt;p&gt;Around September 2022, the Remix team introduced React Router 6.4, packed with latest features and patterns that streamline various tasks within your React application. &lt;/p&gt;

&lt;p&gt;These enhancements are designed to simplify behaviors like loading and updating data, ensuring automatic data revalidation after updates, handling navigation race conditions, managing errors effectively, creating pending and skeleton UIs, and more, all based on the Remix team's insights.&lt;/p&gt;

&lt;p&gt;In this article, we'll mainly delve into the following aspects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Page Navigation&lt;/li&gt;
&lt;li&gt;Data Fetching&lt;/li&gt;
&lt;li&gt;Loading Data into Components&lt;/li&gt;
&lt;li&gt;Efficient Error Management and User-Centric Rendering&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While the allure of trying out new features can be strong, it's advisable to balance innovation with what already works for you. Just like preferring new clothes over old ones. You should adopt features that suit your project's needs. &lt;/p&gt;

&lt;p&gt;Before embracing these enhancements in your next project, take the time to comprehend how they function. This article serves as your guide in understanding and implementing these exciting features effectively. Let’s get started. 😊&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;p&gt;Before we continue, make sure you have your project setup in your local machine. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Basic understanding of React.&lt;/li&gt;
&lt;li&gt;Install the new react application and run the application&lt;/li&gt;
&lt;li&gt;Install the latest version of &lt;code&gt;react-router-dom&lt;/code&gt; → &lt;code&gt;npm install react-router-dom&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Page navigation
&lt;/h3&gt;

&lt;p&gt;With React Router 6.4, navigating through your application's pages has become remarkably simpler, requiring fewer lines of code.&lt;/p&gt;

&lt;p&gt;Page navigation, or routing, is an indispensable aspect of building React applications. It's a fundamental skill that enables you to showcase content dynamically based on specific routes, all without the need for page refresh. This not only leads to a smoother user experience but also optimizes your application's performance. &lt;/p&gt;

&lt;p&gt;There are instances where you want to seamlessly display content as users explore different sections of your app, and React Router 6.4 equips you with the tools to achieve this efficiently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;i. Setting up Routes in React Router 6.4+&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Prior to delving into route configuration, ensure that &lt;code&gt;react-router-dom&lt;/code&gt; is present in your &lt;code&gt;package.json&lt;/code&gt; file. If it's not already there, you can add it by executing the command &lt;code&gt;npm install react-router-dom&lt;/code&gt; in your terminal. This step is essential as it provides the foundation for establishing and managing routes using React Router 6.4+. Once you have this dependency in place, you'll be ready to define and organize the navigation paths within your application effectively.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjsq0s4c6f0a3hl3vh7s6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjsq0s4c6f0a3hl3vh7s6.png" alt="package dependencies"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let's delve into router configuration.&lt;/p&gt;

&lt;p&gt;To get started, we import &lt;code&gt;createBrowserRouter&lt;/code&gt; from &lt;code&gt;react-router-dom&lt;/code&gt;. This function plays a crucial role in directing the routing of our application within the updated router version. This crucial step sets the stage for defining how different routes will guide users through your application's various pages and components. With &lt;code&gt;createBrowserRouter&lt;/code&gt;, you gain the power to establish clear paths for seamless navigation, making the most out of React Router 6.4's capabilities.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { createBrowserRouter, createRoutesFromElements, RouterProvider, Route, Link, Outlet  } from 'react-router-dom'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside your &lt;code&gt;App.js&lt;/code&gt; component, declare a variable named router and assign it to &lt;code&gt;createBrowserRouter&lt;/code&gt; function.&lt;/p&gt;

&lt;p&gt;Configuring routes involves two distinct approaches, each offering its advantages:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Array of Objects:&lt;/strong&gt; One option is to define routes through an array of objects. Each object contains properties such as path and element. This clear configuration helps map out the paths and associated components for navigation.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const router = createBrowserRouter([
    { path: '/', element: &amp;lt;Home /&amp;gt;},
    { path: '/about', element: &amp;lt;About /&amp;gt; }
  ])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Using &lt;code&gt;createRoutesFromElements&lt;/code&gt;:&lt;/strong&gt; Alternatively, leverage createRoutesFromElements within createBrowserRouter. Here, you use route definitions as JSX elements. The primary route, functioning as a parent, shapes the layout that accommodates all subsequent child routes.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const router = createBrowserRouter(createRoutesFromElements(
    &amp;lt;Route path='/' element={&amp;lt;Root /&amp;gt;} &amp;gt;
      &amp;lt;Route index element={&amp;lt;Home /&amp;gt;} /&amp;gt; //default route
      &amp;lt;Route path='/about' element={&amp;lt;About /&amp;gt;} /&amp;gt;
    &amp;lt;/Route&amp;gt; 
  ));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you proceed, it's important to note that the &lt;strong&gt;Root&lt;/strong&gt; component, if use as an element within a Route, might require creating it in a separate file or even within the same &lt;code&gt;App.js&lt;/code&gt; file, depending on the project's structure and your preferences. This ensures a well-organized and efficient routing structure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ii. Navigating between pages in a client-side application using React Router 6.4+&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the context of this article, we'll illustrate page navigation using two(2) components:&lt;/p&gt;

&lt;p&gt;Home component and About component&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Content of the Home Component
const Home = () =&amp;gt; {
  return (
    &amp;lt;div&amp;gt;This is the Home page&amp;lt;/div&amp;gt;
  )
}

export default Home
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Content of the About Component
const About = () =&amp;gt; {
  return (
    &amp;lt;div&amp;gt;This is the About page&amp;lt;/div&amp;gt;
  )
}

export default About
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Incorporate the links to our pages using the &lt;code&gt;&amp;lt;Link&amp;gt;&lt;/code&gt; from react-router-dom, ensuring alignment with the corresponding paths defined in the router variable.&lt;/p&gt;

&lt;p&gt;When utilizing the &lt;code&gt;&amp;lt;Link&amp;gt;&lt;/code&gt;, the &lt;code&gt;to&lt;/code&gt; attribute plays a crucial role. Essentially, clicking on the text "About" triggers the inclusion of &lt;code&gt;/about&lt;/code&gt; in the page's URL. Subsequently, the designated component with the identical path from the router variable, in this instance &lt;code&gt;&amp;lt;Route path='/about' element={&amp;lt;About /&amp;gt;} /&amp;gt;&lt;/code&gt;, gets rendered. &lt;/p&gt;

&lt;p&gt;This seamless interaction enables users to effortlessly navigate between content while maintaining a coherent and engaging user experience.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Root component or element
const Root = () =&amp;gt; {
  return (
    &amp;lt;div&amp;gt;
    &amp;lt;header&amp;gt;
      &amp;lt;Link to="/"&amp;gt;Home&amp;lt;/Link&amp;gt;
      &amp;lt;Link to="/about"&amp;gt;About&amp;lt;/Link&amp;gt;
    &amp;lt;/header&amp;gt;
    &amp;lt;main&amp;gt;
        &amp;lt;Outlet/&amp;gt;
    &amp;lt;/main&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A closer observation reveals that the parent Route within the router variable, housing the Root component, holds the path &lt;code&gt;‘/’&lt;/code&gt;. Consequently, when launching the application, the default route, which is &lt;strong&gt;Home&lt;/strong&gt;, is displayed due to its position as the index route within the Root Route.&lt;/p&gt;

&lt;p&gt;Within the primary element, the &lt;code&gt;&amp;lt;Outlet/&amp;gt;&lt;/code&gt; takes center stage. Its purpose is to seamlessly render the content of the Route nested within the Root Route.&lt;/p&gt;

&lt;p&gt;However, at this juncture, our root file - &lt;code&gt;App.js&lt;/code&gt;, lacks direct access to the previously crafted router variable. To bridge this gap, the solution lies in utilizing the &lt;code&gt;&amp;lt;RouterProvider/&amp;gt;&lt;/code&gt; from react-router-dom. By embedding router as a prop within &lt;code&gt;&amp;lt;RouterProvider/&amp;gt;&lt;/code&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;div className='App'&amp;gt;
    &amp;lt;RouterProvider router={router} /&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is our final result working as intended.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy99hhuvd49bijjtivsiz.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy99hhuvd49bijjtivsiz.gif" alt="route pages"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Data Fetching
&lt;/h3&gt;

&lt;p&gt;In React Router 6.4+, data fetching assumes a crucial role, facilitating swift data retrieval each time a page is rendered. If you're keen to delve deeper, I've penned an article detailing data access within components, leveraging React Hooks. &lt;/p&gt;

&lt;p&gt;Feel free to explore it: &lt;a href="https://dev.to/esedev/how-to-pass-and-access-data-from-one-route-to-another-with-uselocation-usenavigate-usehistory-hooks-1g5m"&gt;How to pass and access data from one route to another with useLocation, useNavigate, useHistory hooks&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For software developers, data fetching ranks high in importance when building applications. In essence, data fetching entails retrieving information from a server and seamlessly presenting it in response to user requests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;i. How to load data from API in React Router 6.4+&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The latest React Router version has made fetching data from APIs incredibly simple, reducing the amount of code required.&lt;/p&gt;

&lt;p&gt;This is achieved through the use of &lt;code&gt;loader&lt;/code&gt; props, which streamline the process of fetching data from an API before the component is displayed in the browser. As a result, there's no longer a need to employ the &lt;code&gt;useEffect&lt;/code&gt; hook to fetch data during component rendering. It's like achieving two goals with a single action.&lt;/p&gt;

&lt;p&gt;Traditionally, when fetching data in a component, developers used the useEffect hook to fetch data and often utilized the useState hook to store it. In React Router 6.4+, this process is simplified further using the &lt;code&gt;useLoaderData()&lt;/code&gt; hook. This means you don't have to rely on either the useEffect or useState hook to store API data.&lt;/p&gt;

&lt;p&gt;In our illustration, we'll work with the free &lt;a href="https://pokeapi.co/" rel="noopener noreferrer"&gt;Pokemon API&lt;/a&gt; and create a dedicated page to showcase this streamlined data loading approach.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Poke = () =&amp;gt; {

    const result = useLoaderData()

  return (
      &amp;lt;div&amp;gt;
          This is the Poke page
          {
              data.game_indices.map(itm =&amp;gt; (
                  &amp;lt;div key={itm.version.name}&amp;gt;
                      &amp;lt;p &amp;gt;
                          {itm.version.name}
                      &amp;lt;/p&amp;gt;
                  &amp;lt;/div&amp;gt;

              ))
          }
    &amp;lt;/div&amp;gt;
  )
}

export default Poke

export async function pokeData(){
    const response = await fetch('https://pokeapi.co/api/v2/pokemon/ditto')
    .then(response =&amp;gt; response.json())
    const resData = await response
    return resData;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Examining the code above, we're using the fetch API to grab data from the Pokemon API. Importantly, getting data doesn't have to happen in the exact same place where we want to show it. &lt;/p&gt;

&lt;p&gt;We can actually fetch data in a different component, then bring the function that fetches the data over and connect it to a specific pathway.&lt;/p&gt;

&lt;p&gt;When we want to display the data we fetched using the &lt;code&gt;pokeData&lt;/code&gt; function in the Poke component, we'll need to tap into something called "loader props". This is like a special tool that the Poke component gets. With this tool, we hand over the &lt;code&gt;pokeData&lt;/code&gt; function, and it makes sure the data is fetched and ready to be shown when the Poke component shows up. It's a bit like preparing all the ingredients before cooking a meal. This way, things are nicely organized and work smoothly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import './App.css'
import { createBrowserRouter, createRoutesFromElements, RouterProvider, Route, Link, Outlet } from 'react-router-dom'
import Home from './page/Home'
import About from './page/About';
import Poke from './page/Poke';
import { pokeData } from './page/Poke' //imported data function

function App() {
  const router = createBrowserRouter(createRoutesFromElements(
    &amp;lt;Route path='/' element={&amp;lt;Root /&amp;gt;} &amp;gt;
      &amp;lt;Route index element={&amp;lt;Home /&amp;gt;} /&amp;gt;
      &amp;lt;Route path='/about' element={&amp;lt;About /&amp;gt;} /&amp;gt;
      &amp;lt;Route
        path='/poke'
        element={&amp;lt;Poke /&amp;gt;}
        loader={pokeData}
      /&amp;gt;
    &amp;lt;/Route&amp;gt; 
  ));

  return (
    &amp;lt;div className='App'&amp;gt;
      &amp;lt;RouterProvider router={router} /&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So whenever we visit &lt;code&gt;/poke&lt;/code&gt; route, the pokeData function will run ahead of time, fetch the data, store the data response in the result by setting it to &lt;code&gt;useLoaderData()&lt;/code&gt; hook from react-router-dom, and voila………..! you have access to render the data in that page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpafzpda67yobc919y0j1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpafzpda67yobc919y0j1.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Error handling
&lt;/h3&gt;

&lt;p&gt;Sometimes, when you go to a page, you might see a big "404 Not Found" message with some other explanations. This basically means that the page you're looking for isn't there or doesn't exist.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3tl1ybbxro89k1ftvdnk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3tl1ybbxro89k1ftvdnk.png" alt="404 page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You wouldn't like to present users with a strange-looking page like that when they're trying to reach the poke page, especially if the API data isn't working or no response is returned. &lt;/p&gt;

&lt;p&gt;The good news is, React Router 6.4+ makes it simple for you to manage these situations. It provides ways to show a more attractive error page using tools like &lt;code&gt;errorElement&lt;/code&gt; props and &lt;code&gt;useRouteError()&lt;/code&gt;hooks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;i. How to handle and render errors with useRouteError hook&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To begin, we'll adjust our fetch API function to enable us to see if the fetch was successful or not. You can find guidance on this at &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#checking_that_the_fetch_was_successful" rel="noopener noreferrer"&gt;MDN: Checking that fetch was successful&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export async function pokeData() {
    try {
    const res = await fetch(
      "https://pokeapi.co/api/v2/pokemon/ditto"
    );
    const resData = await res.json();
    if (!res.ok) {
        throw Error('Name is not available!');
    }
    return resData;
  } catch (error) {
    throw Error('Name is not available!');
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a separate page component for the Error Page, import &lt;code&gt;useRouteError&lt;/code&gt; hooks from &lt;code&gt;react-router-dom&lt;/code&gt;, and assign it to a variable which will be the error that you throw in pokeData function. Using the variable you can be able to access the error message on that page.&lt;/p&gt;

&lt;p&gt;Create a new component for the Error Page, and bring in the &lt;code&gt;useRouteError&lt;/code&gt; hooks from &lt;code&gt;react-router-dom&lt;/code&gt;. Set it to a variable, which will hold the error you create in the pokeData function. This variable lets you get the error message and display it on that page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Link, useRouteError } from "react-router-dom"

const PokeError = () =&amp;gt; {
  const error = useRouteError();

  return (
      &amp;lt;div&amp;gt;
          &amp;lt;p&amp;gt;{error.message}&amp;lt;/p&amp;gt;
          &amp;lt;Link to='/'&amp;gt;Back to home page&amp;lt;/Link&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}

export default PokeError
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pass the error using the &lt;code&gt;errorElement&lt;/code&gt; props into the associated Route and simply give it the Error page as the value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import './App.css'
import { createBrowserRouter, createRoutesFromElements, RouterProvider, Route, Link, Outlet } from 'react-router-dom'
import Home from './page/Home'
import About from './page/About';
import Poke from './page/Poke';
import { pokeData } from './page/Poke'
import PokeError from './page/PokeError';

function App() {
  const router = createBrowserRouter(createRoutesFromElements(
    &amp;lt;Route path='/' element={&amp;lt;Root /&amp;gt;}&amp;gt;
      &amp;lt;Route index element={&amp;lt;Home /&amp;gt;} /&amp;gt;
      &amp;lt;Route path='/about' element={&amp;lt;About /&amp;gt;} /&amp;gt;
      &amp;lt;Route
        path='/poke'
        element={&amp;lt;Poke /&amp;gt;}
        loader={pokeData}
        errorElement = { &amp;lt;PokeError/&amp;gt;}
      /&amp;gt;
    &amp;lt;/Route&amp;gt; 
  ));

  return (
    &amp;lt;div className='App'&amp;gt;
      &amp;lt;RouterProvider router={router} /&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; You have two options: you can use the &lt;code&gt;errorElement&lt;/code&gt; props in either the main parent Route or the associated Route.&lt;/p&gt;

&lt;p&gt;If the errorElement props are set in the parent Route, and you attempt to go to an invalid route like &lt;code&gt;/pokes&lt;/code&gt;, the Error page will show up as expected. However, the error message specific to the Poke page won't display, and you'll see the other content instead.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd2ulnzorn624j5b7ybeu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd2ulnzorn624j5b7ybeu.png" alt="/pokes error page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo8m4j3d2w7570e2dojey.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo8m4j3d2w7570e2dojey.png" alt="/poke error page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In conclusion, React Router 6.4+ brings exciting features that make building React applications easier. It simplifies tasks like loading and updating data, managing errors, and improving the user interface. &lt;/p&gt;

&lt;p&gt;Navigating between pages is now simpler and faster with the new routing setup. Data fetching, which is crucial, is made easier with the useLoaderData() hook. It loads data before the page is rendered, resulting in quicker loading times. Handling errors is also improved, making error messages more user-friendly.  &lt;/p&gt;

&lt;p&gt;React Router 6.4+ provides valuable tools that enhance navigation, data management, and error handling, making React development more efficient and user-focused.&lt;/p&gt;

</description>
      <category>react</category>
      <category>datafetching</category>
      <category>errors</category>
      <category>api</category>
    </item>
    <item>
      <title>Create React App vs Vite: Which one should you choose for your next React Project?</title>
      <dc:creator>Esther Itolima</dc:creator>
      <pubDate>Fri, 10 Mar 2023 22:52:37 +0000</pubDate>
      <link>https://forem.com/esedev/create-react-app-vs-vite-which-one-should-you-choose-for-your-next-react-project-5268</link>
      <guid>https://forem.com/esedev/create-react-app-vs-vite-which-one-should-you-choose-for-your-next-react-project-5268</guid>
      <description>&lt;p&gt;&lt;em&gt;&lt;strong&gt;React&lt;/strong&gt;&lt;/em&gt; is an immensely popular JavaScript library for building web applications, and it has a thriving ecosystem of tools and utilities. One such tool is Create React App, a command-line interface (CLI) tool that provides a pre-configured development environment for React projects. However, a newer contender in this space is &lt;em&gt;&lt;strong&gt;Vite&lt;/strong&gt;&lt;/em&gt;, a build tool that aims to provide a faster and more flexible development experience for modern web projects. In this blog post, we will compare the features of Create React App and Vite to help you decide which one to use for your next project.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Vite ( pronounced /vit/, like "veet") is a build tool and development server that was created to enhance the development experience of modern web applications. It was developed by Evan You, the creator of Vue.js, and it can be used to develop applications in various frameworks, including Vue.js, React, and Angular.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Getting started&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Getting started with &lt;strong&gt;Create React App&lt;/strong&gt; is straightforward - you can create a new project with a single command (&lt;code&gt;npx create-react-app my-app&lt;/code&gt;), and it comes pre-configured with all the necessary settings and dependencies to start building your React application. However, if you want to customize the configuration, you need to eject the app, which can be a time-consuming process and can potentially cause issues if you're not careful.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vite&lt;/strong&gt;, on the other hand, requires a little more setup(&lt;code&gt;npm create vite@latest&lt;/code&gt;), but it provides more flexibility in terms of configuration. You can use Vite to create a new project with your preferred setup, or you can add Vite to an existing project by running a few commands. Vite also provides a comprehensive configuration file that allows you to fine-tune the settings according to your needs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Development server&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Both Create React App and Vite provide a development server that lets you preview your app in the browser as you write code. However, Vite's development server is much &lt;strong&gt;faster&lt;/strong&gt; than Create React App's server, especially when it comes to hot module reloading. This means that you can see the changes you make to your code almost instantly with Vite, making the development process more efficient and enjoyable on like React app which takes time to reload for every changes you make.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Build process&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When it comes to building your application for production, Create React App and Vite take different approaches. Create React App uses webpack to bundle your code and generates an optimized build that you can deploy to a server or a content delivery network (CDN). However, if you want to customize the webpack configuration, you need to eject the app, which can be a significant undertaking.&lt;/p&gt;

&lt;p&gt;Vite, on the other hand, uses &lt;a href="https://rollupjs.org/"&gt;Rollup&lt;/a&gt; to bundle your code, which is known to be faster and builds in milliseconds than webpack. Vite's build process is also highly configurable, and you can fine-tune the settings according to your needs. This makes it easier to optimize your application for performance and reduce its bundle size, which is critical for improving the user experience.&lt;/p&gt;

&lt;p&gt;In conclusion, both Create React App and Vite are excellent tools for developing React applications, and the choice between them ultimately depends on your needs and preferences. &lt;strong&gt;If you want a simple and easy-to-use development environment that gets you up and running quickly&lt;/strong&gt;, Create React App is an excellent choice. &lt;strong&gt;However, if you want a faster and more flexible development experience with better performance and optimization options&lt;/strong&gt;, Vite might be the way to go. Ultimately, it's up to you to weigh the pros and cons of each tool and choose the one that fits your requirements best.&lt;/p&gt;

&lt;p&gt;Whether you're a beginner or an experienced developer, using the right tools is crucial to the success of your project. Create React App and Vite are both excellent options for building React applications, and they both have their strengths and weaknesses. By carefully considering the features of each tool, you can make an informed decision that will help you build better applications faster.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Reference:&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
&lt;a href="https://beta.reactjs.org/learn/start-a-new-react-project"&gt;https://beta.reactjs.org/learn/start-a-new-react-project&lt;/a&gt; &lt;br&gt;
&lt;a href="https://vitejs.dev/guide/"&gt;https://vitejs.dev/guide/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vite</category>
      <category>flexibility</category>
      <category>frontend</category>
      <category>react</category>
    </item>
    <item>
      <title>5 free resources to jumpstart your career in Frontend Development.</title>
      <dc:creator>Esther Itolima</dc:creator>
      <pubDate>Thu, 09 Mar 2023 20:03:43 +0000</pubDate>
      <link>https://forem.com/esedev/5-free-resources-to-jumpstart-your-career-in-frontend-development-ei9</link>
      <guid>https://forem.com/esedev/5-free-resources-to-jumpstart-your-career-in-frontend-development-ei9</guid>
      <description>&lt;p&gt;Frontend programming is a fascinating field that involves developing the user interface of websites and applications. It requires a range of skills, including proficiency in HTML, CSS, and JavaScript. However, learning frontend programming can be an expensive endeavor, especially if you opt for paid courses or boot camps. Fortunately, there are many free resources available online that can help you learn frontend programming without spending more or a dime. In this blog post, we will explore some of the top free resources to learn frontend programming.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://javascript.info/"&gt;&lt;strong&gt;JavaScript Info&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;
JavaScript Info is a widely recognized and comprehensive online learning platform for JavaScript programming language. It offers a vast range of beginner to advanced tutorials, interactive exercises, and practical projects to help individuals master the intricacies of JavaScript. The platform also features an active community forum for learners to discuss concepts, ask questions, and seek guidance from experienced programmers. Whether you're new to JavaScript or an experienced developer, JavaScript Info is an excellent resource for honing your skills and staying up-to-date with the latest industry developments.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/trekhleb/javascript-algorithms"&gt;&lt;strong&gt;JavaScript Algorithms and Data Structures&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;
JavaScript Algorithms and Data Structures is a comprehensive online resource for learning and implementing algorithms and data structures using the JavaScript programming language. The website features detailed explanations, interactive code examples, and practical exercises to help individuals gain a deeper understanding of core computer science concepts such as sorting algorithms, data structures, and graph theory. With a focus on real-world applications, the platform equips learners with the skills and knowledge needed to solve complex programming problems and build robust software applications. Whether you're a beginner or an experienced developer, JavaScript Algorithms and Data Structures is an excellent resource for expanding your technical skills and advancing your career.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.frontendmentor.io/"&gt;&lt;strong&gt;Frontend Mentor&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;
Frontend Mentor is an online platform that provides designers and developers with real-world design challenges to help them improve their skills in front-end development. The platform offers a wide range of projects, from simple to complex, that cover various topics such as HTML, CSS, and JavaScript. Users can choose from various skill levels, including beginner, intermediate, and advanced, and work on the challenges at their own pace. Frontend Mentor also provides detailed design specifications, style guides, and assets to help users create pixel-perfect designs. Additionally, the platform features a community forum where users can share their work, get feedback, and connect with other developers. Whether you're looking to sharpen your skills, build your portfolio, or simply enjoy the challenge of solving real-world design problems, Frontend Mentor is an excellent resource for front-end developers of all levels.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/sindresorhus/awesome"&gt;&lt;strong&gt;Awesome&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;
Awesome is a community-curated list of resources and tools related to various programming languages, frameworks, libraries, and software development topics. The project was started on GitHub as a way for developers to share their favorite resources with others and has since grown into a massive collection of over 28,000 curated lists covering a wide range of topics. Users can browse through the lists to discover new resources, or contribute their own by creating a pull request on GitHub. The project's aim is to make it easier for developers to find high-quality resources and tools, save time, and ultimately improve their productivity. Whether you're a beginner or an experienced developer, Awesome is an excellent resource for discovering new tools and staying up-to-date with the latest industry developments.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.codewars.com/"&gt;&lt;strong&gt;CodeWars&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;
CodeWars is an online platform that provides developers with a fun and challenging way to improve their coding skills by solving programming challenges known as "katas." Users can choose from a wide range of katas that cover various programming languages and skill levels, including beginner, intermediate, and advanced. Each kata presents a unique coding problem that users must solve using the programming language of their choice. Users can then submit their solutions and compare their code with others to learn new techniques and improve their problem-solving skills. CodeWars also features a leaderboard that tracks users' progress and provides an incentive to continue improving. Whether you're looking to improve your coding skills, learn a new programming language, or simply enjoy the challenge of solving complex programming problems, CodeWars is an excellent resource for developers of all levels.&lt;/p&gt;

&lt;p&gt;In conclusion, learning frontend programming doesn't have to be expensive. With the help of these free resources, you can acquire the skills needed to build engaging and interactive user interfaces for websites and applications. Choose the resource that best suits your learning style and start your frontend development journey today. Remember to practice regularly and apply your knowledge to real-world projects to solidify your understanding.&lt;/p&gt;

</description>
      <category>career</category>
      <category>frontend</category>
      <category>webdev</category>
      <category>resources</category>
    </item>
    <item>
      <title>useEffect vs useEffectOnce</title>
      <dc:creator>Esther Itolima</dc:creator>
      <pubDate>Wed, 08 Mar 2023 15:29:17 +0000</pubDate>
      <link>https://forem.com/esedev/useeffect-vs-useeffectonce-2cnk</link>
      <guid>https://forem.com/esedev/useeffect-vs-useeffectonce-2cnk</guid>
      <description>&lt;p&gt;As a developer, you've probably encountered React's useEffect hook, which is used for handling side effects in functional components. While useEffect is a powerful tool, you may not be aware of its more specialized variant, useEffectOnce. In this post, we'll explore the differences between these two hooks and when to use each one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;useEffect()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The useEffect hook is a tool that allows you to execute side effects in &lt;strong&gt;functional components&lt;/strong&gt;. Side effects are actions that occur outside of a component's state updates, such as fetching data, setting timers, or updating the DOM.&lt;/p&gt;

&lt;p&gt;When you use useEffect, you provide a callback function that will be executed after each render cycle. This function may have side effects that need to be cleaned up when the component is unmounted or re-rendered. To do this, you can return a cleanup function from the useEffect callback&lt;/p&gt;

&lt;p&gt;Here's an example of how to use useEffect to fetch data from an API:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useState, useEffect } from 'react';

function MyComponent() {
  const [data, setData] = useState(null);

  useEffect(() =&amp;gt; {
    async function fetchData() {
      const response = await fetch('https://my-api.com/data');
      const jsonData = response.data;
      setData(jsonData);
    }

    fetchData();
  }, []);

  return (
    &amp;lt;div&amp;gt;
      {data ? (
        &amp;lt;ul&amp;gt;
          {data.map(item =&amp;gt; (
            &amp;lt;li key={item.id}&amp;gt;{item.name}&amp;lt;/li&amp;gt;
          ))}
        &amp;lt;/ul&amp;gt;
      ) : (
        &amp;lt;p&amp;gt;Loading...&amp;lt;/p&amp;gt;
      )}
    &amp;lt;/div&amp;gt;
  );
}


export default MyComponent
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we define a state variable called &lt;code&gt;data&lt;/code&gt; and initialize it to &lt;code&gt;null&lt;/code&gt;. We then use useEffect to fetch data from an API and update the &lt;code&gt;data&lt;/code&gt; state variable with the response. The &lt;code&gt;[]&lt;/code&gt; empty array as second argument tells React to only execute the callback once, after the initial render.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;useEffectOnce&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While useEffect is a great general-purpose tool, there are cases where you only need to execute a side effect once, when the component is mounted. This is where useEffectOnce comes in.&lt;/p&gt;

&lt;p&gt;useEffectOnce is a &lt;strong&gt;custom hook&lt;/strong&gt; that wraps useEffect and provides a more concise way to execute a side effect only once. &lt;/p&gt;

&lt;p&gt;_&lt;strong&gt;A custom hook is simply a JavaScript function that starts with the prefix "use". This prefix is important, as it tells React that this function is a hook and can be used with the use keyword within a functional component. Custom hooks can use other built-in hooks such as useState, useEffect, useCallback, etc., to build the desired functionality.&lt;/strong&gt;&lt;br&gt;
_&lt;/p&gt;

&lt;p&gt;Here's what the implementation looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { EffectCallback, useEffect } from 'react'

export function useEffectOnce(effect: EffectCallback) {
  useEffect(effect, []);
}

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

&lt;/div&gt;



&lt;p&gt;As you can see, useEffectOnce accepts a single argument, which is the callback function that will be executed once. It then calls useEffect with the same callback and an empty array as the second argument, which tells React to only execute the callback once, after the initial render.&lt;/p&gt;

&lt;p&gt;Here's an example of how to use useEffectOnce to initialize a third-party library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useEffectOnce } from './useEffectOnce';



function MyComponent() {
const [data, setData] = useState({
name: 'John Doe'
});

  useEffectOnce(() =&amp;gt; {
    console.log('Triggered only once, on mount', { data })
  });

  return &amp;lt;div&amp;gt;My Component&amp;lt;/div&amp;gt;;
}

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

&lt;/div&gt;



&lt;p&gt;In this example, we import the useEffectOnce hook from a separate file and use it to display the &lt;code&gt;data&lt;/code&gt;. The callback function is executed only once, after the initial render.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to use useEffect or useEffectOnce?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So, when should you use useEffect and when should you use useEffectOnce?&lt;/p&gt;

&lt;p&gt;As a general rule, you should use useEffect for side effects that need to be executed on every render, such as updating the DOM based on state changes or fetching data from an API based on props. Use useEffectOnce for side effects that need to be executed only once, such as initializing a third-party library or registering event listeners.&lt;/p&gt;

&lt;p&gt;If you're unsure which hook to use, you can always start with useEffect and refactor to useEffectOnce if you find it necessary to use.&lt;/p&gt;

&lt;p&gt;In conclusion, both useEffect and useEffectOnce are powerful tools for handling side effects in React functional components. Knowing when to use each hook is important for writing efficient and maintainable code. As a general rule, use useEffect for side effects that need to be executed on every render, and useEffectOnce for side effects that need to be executed only once.&lt;/p&gt;

&lt;p&gt;By understanding the differences between these two hooks and using them appropriately, you can write cleaner and more effective code in your React projects.&lt;/p&gt;

&lt;p&gt;Do well to comment which one you have used.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Reference&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
&lt;a href="https://reactjs.org/docs/hooks-effect.html"&gt;https://reactjs.org/docs/hooks-effect.html&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.freecodecamp.org/news/react-useeffect-absolute-beginners/"&gt;https://www.freecodecamp.org/news/react-useeffect-absolute-beginners/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://blog.logrocket.com/useeffect-hook-complete-guide/"&gt;https://blog.logrocket.com/useeffect-hook-complete-guide/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.turing.com/blog/custom-react-js-hooks-how-to-use/"&gt;https://www.turing.com/blog/custom-react-js-hooks-how-to-use/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.freecodecamp.org/news/how-to-create-react-hooks/"&gt;https://www.freecodecamp.org/news/how-to-create-react-hooks/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://blog.logrocket.com/create-your-own-custom-react-hooks/"&gt;https://blog.logrocket.com/create-your-own-custom-react-hooks/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://betterprogramming.pub/react-custom-hooks-with-real-life-examples-c259139c3d71"&gt;https://betterprogramming.pub/react-custom-hooks-with-real-life-examples-c259139c3d71&lt;/a&gt;&lt;br&gt;
&lt;a href="https://morioh.com/p/2784310361ef"&gt;https://morioh.com/p/2784310361ef&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>reacthook</category>
      <category>customhook</category>
      <category>fuctionalcomponent</category>
    </item>
    <item>
      <title>Scribe Chrome Extension: The Ultimate Tool for Documenting Your Processes</title>
      <dc:creator>Esther Itolima</dc:creator>
      <pubDate>Tue, 07 Mar 2023 10:25:42 +0000</pubDate>
      <link>https://forem.com/esedev/scribe-chrome-extension-the-ultimate-tool-for-documenting-your-processes-4kif</link>
      <guid>https://forem.com/esedev/scribe-chrome-extension-the-ultimate-tool-for-documenting-your-processes-4kif</guid>
      <description>&lt;p&gt;In today’s fast-paced business world, effective process documentation is essential for streamlining workflows and increasing productivity. The Scribe Chrome Extension is the ultimate tool for documenting your processes, making it easier than ever to capture and organize key information and collaborate with team members. With its advanced features, including automatic recording of user activity, manual note-taking and tagging, audio and video recording, and integration with project management tools, the Scribe Chrome Extension is the perfect solution for any individual or team looking to improve their productivity and achieve their goals more efficiently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Scribe?&lt;/strong&gt;&lt;br&gt;
Scribe is a productivity tool that is available as a Chrome extension. It is designed to help users capture and organize information in a structured and efficient manner. With Scribe, users can create workspaces to organize their projects, documents to capture information, and tags to categorize and search for their content. The extension also includes a rich text editor that allows users to format text, add images, and embed links to external resources. Scribe can be used for a variety of use cases, such as process documentation, project management, and knowledge management. It is a versatile tool that can help users streamline their workflow and increase productivity. &lt;em&gt;Scribe was founded in 2019&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Scribe generates a step-by-step guide through your cursor clicks and the keystroke. Scribe is totally free and you can also use Scribe on your desktop by simply upgrading to the premium version which includes some additional features like customizing screenshots, branded guides, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key features of the Scribe Chrome Extension.&lt;/strong&gt;&lt;br&gt;
The Scribe Chrome Extension offers a range of powerful features for documenting your processes, including:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Automatic recording of user activity:&lt;/strong&gt; Scribe records every action you take on your computer, including website visits, mouse clicks, and keyboard strokes, making it easy to capture and analyze your workflow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Manual note-taking and tagging:&lt;/strong&gt; You can also manually take notes and tag them with keywords and labels, making it easy to find and organize your information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Audio and video recording:&lt;/strong&gt; Scribe allows you to record audio and video notes, enabling you to capture spoken information, presentations, and other content that might be difficult to capture in writing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Integration with project management tools:&lt;/strong&gt; Scribe integrates with popular project management tools like Asana and Trello, allowing you to create tasks and track your progress directly from the extension.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Collaboration features:&lt;/strong&gt; Scribe makes it easy to collaborate with your team members, allowing you to share notes and recordings, assign tasks, and leave feedback and comments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Centralised information:&lt;/strong&gt; Scribe creates a centralised repository of information, making it easy to access and share knowledge across your organisation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Privacy and security:&lt;/strong&gt; Scribe takes privacy and security seriously, encrypting all data and giving you control over who has access to your information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use cases of Scribe&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Scribe can be used to document processes, workflows, and procedures in a clear and organized way. This can help teams optimize their processes and improve collaboration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scribe can be used to capture and organize knowledge within an organization. This can include best practices, procedures, and company policies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scribe can be used to document project plans, tasks, and milestones. This can help teams stay on track and ensure that projects are completed on time and within budget.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scribe can be used to document customer support procedures, such as troubleshooting steps and best practices. This can help support teams resolve issues more efficiently and effectively.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scribe can be used to create training materials and documentation for new hires. This can help new employees get up to speed more quickly and become productive members of the team.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;How to use the Scribe Chrome Extension for documenting your processes&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sepamVg3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rv4i7qcuhel3wt4cgr5f.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sepamVg3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rv4i7qcuhel3wt4cgr5f.jpeg" alt="how to use scribe chrome extension" width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Install the Scribe Chrome Extension from the Chrome Web Store.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the Scribe icon in your browser toolbar to open the extension.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on ‘Start recording’ in the extension dropdown.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the blinking red button in the corner of your screen and select ‘Complete Recording’&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can create a new workspace for your project and give it a descriptive name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add a new document to your workspace by clicking on the “New Document” button.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Give your document a title that reflects its content.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use the rich text editor to add text, images, and links to your document.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use the “Tags” feature to organize your documents by topic or category.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use the “Export” feature to download your document as a PDF or text file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use the “Share” feature to collaborate with team members or share your document with others.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use the “Search” feature to quickly find information within your workspace.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In conclusion, the Scribe Chrome Extension is a powerful tool for documenting your processes. With its intuitive interface and robust feature set, it makes it easy to capture and organize information in a way that is accessible and actionable. Whether you are a business owner, project manager, or team leader, Scribe can help you streamline your processes, improve collaboration, and boost productivity. By using Scribe to document your processes, you can ensure that your team is aligned, your workflows are optimized, and your projects are successful. So if you’re looking for a tool that can help you take your process documentation to the next level, look no further than the Scribe Chrome Extension.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Reference:&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
&lt;a href="https://scribehow.com/page/Getting_Started_With_Scribe__eR6WdPtoTOuhiSZ3EcGLmw"&gt;https://scribehow.com/page/Getting_Started_With_Scribe__eR6WdPtoTOuhiSZ3EcGLmw&lt;/a&gt;&lt;/p&gt;

</description>
      <category>scribe</category>
      <category>documentprocess</category>
      <category>chromeextension</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Manipulating the browser's history in react</title>
      <dc:creator>Esther Itolima</dc:creator>
      <pubDate>Sun, 05 Mar 2023 03:09:53 +0000</pubDate>
      <link>https://forem.com/esedev/manipulating-the-browsers-history-in-react-5agm</link>
      <guid>https://forem.com/esedev/manipulating-the-browsers-history-in-react-5agm</guid>
      <description>&lt;p&gt;Manipulating the browser's history stack can be a powerful tool for building more interactive and seamless web applications. The history object provided by the browser's DOM API allows you to add, remove, and modify entries in the history stack, enabling you to create custom navigation flows and advanced features like back/forward functionality. In this article, we'll explore how to use the &lt;code&gt;history&lt;/code&gt; object to manipulate the browser's history stack and build more powerful web applications.&lt;/p&gt;

&lt;p&gt;React Router provides several hooks to manipulate the browser's history, including &lt;code&gt;useHistory&lt;/code&gt;, &lt;code&gt;useLocation&lt;/code&gt;, and &lt;code&gt;useNavigate&lt;/code&gt;. These hooks allow you to programmatically navigate to different routes, go back and forth in the history stack, and even modify the history stack to achieve a custom user experience. In this article we will be focusing on manipulating the browser's history using &lt;code&gt;useHistory&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;&lt;code&gt;useHistory&lt;/code&gt; is available in &lt;strong&gt;react-router v5&lt;/strong&gt; and for you to use &lt;code&gt;useHistory&lt;/code&gt; you need to properly setup your application in other to use React router -&lt;a href="https://v5.reactrouter.com/web/api/Hooks/usehistory" rel="noopener noreferrer"&gt;https://v5.reactrouter.com/web/api/Hooks/usehistory&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Wrapping the entire application with &lt;code&gt;&amp;lt;BrowserRouter&amp;gt;&lt;/code&gt; is indeed a necessary step to access the history object. This provides a global history object that can be accessed using the useHistory hook.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Additionally, it is important to note that when using the history.push method, you need to provide a valid route instead of a relative file path. This can be set up using the  component provided by React Router.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here are some &lt;strong&gt;common scenarios&lt;/strong&gt; where you might want to manipulate the browser's history:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Programmatic navigation: You might want to navigate to a different route in response to a user action or a component state change.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Conditional navigation: You might want to conditionally navigate to a different route based on some logic, such as whether the user is authenticated or the user input is valid.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Redirects: You might want to redirect the user to a different route or an external URL.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Modifying the history stack: You might want to add, remove, or replace entries in the history stack to achieve a custom navigation experience.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;React Router provides the following methods to manipulate the browser's history:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;push&lt;/code&gt;: Adds a new entry to the history stack and navigates to the specified route.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;replace&lt;/code&gt;: Replaces the current entry in the history stack with a new one and navigates to the specified route.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;go&lt;/code&gt;: Moves back or forward in the history stack by the specified number of entries.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;goBack&lt;/code&gt;: Moves back one entry in the history stack.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;goForward&lt;/code&gt;: Moves forward one entry in the history stack.&lt;/p&gt;

&lt;p&gt;Let's take a look at an example of how to use useHistory hook to push a new entry to the history stack:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useHistory } from "react-router-dom";

const MyComponent = () =&amp;gt; {
  const history = useHistory();

  const handleClick = () =&amp;gt; {
    history.push("/new-route");
  };

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;button onClick={handleClick}&amp;gt;Go to new route&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

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

&lt;/div&gt;



&lt;p&gt;You can use similar code with the replace method to replace the current entry in the history stack with a new one. The go, goBack, and goForward methods allow you to move back and forth in the history stack.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
we have successfully explore how to use the history object to manipulate the browser's history stack so as to build more powerful web applications.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;useHistory is a hook in React Router v5 for navigating pages in your react application&lt;/li&gt;
&lt;li&gt;we explore the different methods we can use to manipulate browser' history&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>discuss</category>
      <category>gratitude</category>
      <category>etiquette</category>
    </item>
    <item>
      <title>How to pass and access data from one route to another with useLocation, useNavigate, useHistory hooks.</title>
      <dc:creator>Esther Itolima</dc:creator>
      <pubDate>Fri, 03 Mar 2023 23:14:51 +0000</pubDate>
      <link>https://forem.com/esedev/how-to-pass-and-access-data-from-one-route-to-another-with-uselocation-usenavigate-usehistory-hooks-1g5m</link>
      <guid>https://forem.com/esedev/how-to-pass-and-access-data-from-one-route-to-another-with-uselocation-usenavigate-usehistory-hooks-1g5m</guid>
      <description>&lt;p&gt;When building a React application with multiple routes, passing data between routes can be challenging. Fortunately, React Router provides several hooks that allow you to pass props and access data from one route to another, including &lt;code&gt;useNavigate&lt;/code&gt;, &lt;code&gt;useHistory&lt;/code&gt;, and &lt;code&gt;useLocation&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;With these hooks, you can easily pass data between components, and retrieve data from the current location object.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore how to use these hooks to pass props and access data from one route to another in your React application. We'll cover how to pass data using state and how to retrieve data from the location object.&lt;/p&gt;

&lt;p&gt;Whether you're building a simple single-page application or a complex multi-page application, these hooks can help you build more efficient and user-friendly navigation while also allowing you to easily pass and access data between routes.&lt;/p&gt;

&lt;p&gt;In the course of this article, I will be using 2 different components for my illustration. The first component is the sending component (ProfileOne) and the other is the receiving component(ProfileTwo). I will be showing you the different ways you can achieve it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;useHistory()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;We will create a component called ProfileOne and define the data that you want to pass.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use the &lt;code&gt;useHistory&lt;/code&gt; hook to push the new route and pass the state object as the second argument.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the receiving component, use the useLocation hook to access the state object and retrieve the passed data.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note that by default the location variable have some key values in which we can use to achieve what we want.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pathname, search, hash, state, key&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and in the course of this article we will be using &lt;code&gt;state&lt;/code&gt; as a prop with the data you want to pass along when calling our hook.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useHistory } from "react-router-dom";

const ProfileOne = () =&amp;gt; {
  const history = useHistory();
  const data = { name: "John", age: 30 };

  const handleClick = () =&amp;gt; {
    history.push({ pathname: "/profile-two", state: data });
  };

  return &amp;lt;button onClick={handleClick}&amp;gt;Go to ProfileTwo&amp;lt;/button&amp;gt;;
};

export default ProfileOne;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useLocation } from "react-router-dom";

const ProfileTwo = () =&amp;gt; {
  const location = useLocation();
  const data = location.state;

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;p&amp;gt;Name: {data.name}&amp;lt;/p&amp;gt;
      &amp;lt;p&amp;gt;Age: {data.age}&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

export default ProfileTwo;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/elated-jones-m1dglu"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;useNavigation&lt;/strong&gt;&lt;br&gt;
Same process except importing useNavigation instead of useHistory in step 2.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useNavigate } from "react-router-dom";

const ProfileOne = () =&amp;gt; {
  const navigate = useNavigate();
  const data = { name: "John", age: 30 };

  const handleClick = () =&amp;gt; {
    navigate("/profile-two", { state: data });
  };

  return &amp;lt;button onClick={handleClick}&amp;gt;Go to ProfileTwo&amp;lt;/button&amp;gt;;
};

export default ProfileOne;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useLocation } from "react-router-dom";

const ProfileTwo = () =&amp;gt; {
  const location = useLocation();
  const data = location.state;

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;p&amp;gt;Name: {data.name}&amp;lt;/p&amp;gt;
      &amp;lt;p&amp;gt;Age: {data.age}&amp;lt;/p&amp;gt;
      Hello
    &amp;lt;/div&amp;gt;
  );
};

export default ProfileTwo;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/bold-aryabhata-psw9o9"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bonus point&lt;/strong&gt;&lt;br&gt;
You can also use &lt;code&gt;Link&lt;/code&gt; element to pass data from one route to another by including the &lt;code&gt;state&lt;/code&gt; prop inside of the &lt;code&gt;Link&lt;/code&gt; element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Link } from "react-router-dom";

const ProfileOne = () =&amp;gt; {
  const data = { name: "John", age: 30 };

  return (
    &amp;lt;Link to="/profile-two" state={{ fromHome: { data } }}&amp;gt;
      Go to ProfileTwo
    &amp;lt;/Link&amp;gt;
  );
};

export default ProfileOne;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;fromHome&lt;/code&gt; indicate where the data is coming and you can decide to use any name of your choice.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useLocation } from "react-router-dom";

const ProfileTwo = () =&amp;gt; {
  const location = useLocation();
  const { fromHome } = location.state;
  let data = fromHome.data;

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;p&amp;gt;Name: {data.name}&amp;lt;/p&amp;gt;
      &amp;lt;p&amp;gt;Age: {data.age}&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

export default ProfileTwo;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In conclusion, passing props and accessing data from one route to another is an essential part of building complex web applications with React. React Router provides several hooks, including useNavigation, useHistory, and useLocation, to help you navigate between routes and pass data along the way.&lt;/p&gt;

&lt;p&gt;By mastering these hooks, you can build complex, interactive web applications that provide a seamless user experience. Whether you're building a simple blog or a full-fledged e-commerce site, React Router's navigation hooks provide the tools you need to build your app's navigation logic. So go ahead and start exploring these hooks to take your React applications to the next level!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Reference&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ui.dev/react-router-pass-props-to-link" rel="noopener noreferrer"&gt;https://ui.dev/react-router-pass-props-to-link&lt;/a&gt;&lt;br&gt;
&lt;a href="https://v5.reactrouter.com/core/api/Hooks/usehistory" rel="noopener noreferrer"&gt;https://v5.reactrouter.com/core/api/Hooks/usehistory&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>mqtt</category>
      <category>authentication</category>
      <category>systemdesign</category>
    </item>
  </channel>
</rss>
