<?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 Idris</title>
    <description>The latest articles on DEV Community by Agboola Idris (@agboolaidris).</description>
    <link>https://dev.to/agboolaidris</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%2F543121%2F68bbc941-dc97-421b-9b86-d1b17006b52d.jpeg</url>
      <title>DEV Community: Agboola Idris</title>
      <link>https://dev.to/agboolaidris</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/agboolaidris"/>
    <language>en</language>
    <item>
      <title>React Performance Optimization: Tips and Techniques for Faster Apps</title>
      <dc:creator>Agboola Idris</dc:creator>
      <pubDate>Sun, 26 Feb 2023 23:16:28 +0000</pubDate>
      <link>https://dev.to/agboolaidris/react-performance-optimization-tips-and-techniques-for-faster-apps-44pl</link>
      <guid>https://dev.to/agboolaidris/react-performance-optimization-tips-and-techniques-for-faster-apps-44pl</guid>
      <description>&lt;p&gt;React is a popular JavaScript library used for building interactive user interfaces for web and mobile applications. However, as the size and complexity of React applications grow, so do the performance issues. Slow rendering times, memory leaks, and a poor user experience can all be caused by performance problems. In this article, we will explore tips and techniques for optimizing React performance to create faster and more efficient applications.&lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  1. Use the React DevTools
&lt;/h2&gt;

&lt;p&gt;The React DevTools is a browser extension that provides insights into the performance of your React application. You can use it to see which components are re-rendering unnecessarily, identify expensive computations, and debug performance issues. The DevTools also includes a profiler, which can help you identify the parts of your code that are causing slow rendering times.&lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  2. Use Memoization
&lt;/h2&gt;

&lt;p&gt;Memoization is a technique for caching the results of expensive computations. In React, you can use the useMemo hook to memoize the results of a function call. This can be particularly useful when you have a component that is re-rendering frequently, but the result of the computation is the same. By memoizing the result, you can avoid unnecessary computations and improve performance.&lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  3. Optimize Your Components
&lt;/h2&gt;

&lt;p&gt;When building a React application, it's important to optimize your components to reduce rendering time. Some techniques for optimizing your components include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using shouldComponentUpdate or React.memo to prevent unnecessary re-renders.&lt;/li&gt;
&lt;li&gt;Avoiding expensive computations in the render method.&lt;/li&gt;
&lt;li&gt;Using functional components instead of class components where possible.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  4. Use a Virtual DOM
&lt;/h2&gt;

&lt;p&gt;React uses a virtual DOM to update the user interface. This is a lightweight representation of the actual DOM that React uses to identify changes and update the real DOM. By using a virtual DOM, React can avoid costly DOM updates and improve performance.&lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  5. Minimize DOM Updates
&lt;/h2&gt;

&lt;p&gt;When rendering your React components, it's important to minimize the number of updates to the DOM. You can do this by using techniques like batching updates, deferring updates, and using CSS transitions to animate changes. This can help improve performance and reduce the risk of memory leaks.&lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  6. Use Code Splitting
&lt;/h2&gt;

&lt;p&gt;Code splitting is a technique for splitting your application code into smaller, more manageable chunks. This can help reduce the initial load time of your application and improve performance. In React, you can use tools like Webpack and React.lazy to implement code splitting.&lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  7. Optimize Images and Other Media
&lt;/h2&gt;

&lt;p&gt;Images and other media can be a significant source of performance issues in React applications. To optimize images and other media, you can use techniques like lazy loading, compression, and using the appropriate file format. By optimizing your images and other media, you can reduce the load time of your application and improve performance.&lt;br&gt;
 &lt;/p&gt;

&lt;p&gt;In conclusion, optimizing React performance is essential for creating fast and efficient applications. By using tools like the React DevTools, memoization, and code splitting, you can improve the performance of your application and provide a better user experience. Additionally, optimizing your components, minimizing DOM updates, and optimizing images and other media can further improve the performance of your React application. Feel free to share your feedback 👇&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
      <category>programming</category>
    </item>
    <item>
      <title>Factors to consider before chosing technology to build your product</title>
      <dc:creator>Agboola Idris</dc:creator>
      <pubDate>Mon, 06 Feb 2023 08:10:34 +0000</pubDate>
      <link>https://dev.to/agboolaidris/factors-to-consider-before-chosing-technology-to-build-your-product-2gm1</link>
      <guid>https://dev.to/agboolaidris/factors-to-consider-before-chosing-technology-to-build-your-product-2gm1</guid>
      <description>&lt;p&gt;When choosing a technology to build your product, there are several factors to consider&lt;br&gt;
  &lt;/p&gt;

&lt;h2&gt;
  
  
  1. Problem fit:
&lt;/h2&gt;

&lt;p&gt;Choose a technology that is well-suited to solve the specific problem you're trying to address with your product.&lt;br&gt;
  &lt;/p&gt;

&lt;h2&gt;
  
  
  2. Development time and cost:
&lt;/h2&gt;

&lt;p&gt;Consider the time and resources required to develop the product using the technology, as well as the ongoing maintenance costs.&lt;br&gt;
  &lt;/p&gt;

&lt;h2&gt;
  
  
  3. Scalability:
&lt;/h2&gt;

&lt;p&gt;Choose a technology that can easily scale as your product grows and evolves.&lt;br&gt;
  &lt;/p&gt;

&lt;h2&gt;
  
  
  4. User experience:
&lt;/h2&gt;

&lt;p&gt;Make sure the technology supports a seamless user experience and provides the features and functionality your users need.&lt;br&gt;
  &lt;/p&gt;

&lt;h2&gt;
  
  
  5. Integration with existing systems:
&lt;/h2&gt;

&lt;p&gt;Consider how well the technology integrates with other systems and tools you already use.&lt;br&gt;
  &lt;/p&gt;

&lt;h2&gt;
  
  
  6. Technical skills:
&lt;/h2&gt;

&lt;p&gt;Make sure you have the technical skills and resources necessary to develop and maintain the product using the technology.&lt;br&gt;
  &lt;/p&gt;

&lt;h2&gt;
  
  
  7. Support and community:
&lt;/h2&gt;

&lt;p&gt;Look for a technology that has a strong community and readily available support to help you overcome challenges and keep the product up-to-date.&lt;br&gt;
  &lt;/p&gt;

&lt;h2&gt;
  
  
  8. Future plans:
&lt;/h2&gt;

&lt;p&gt;Consider the future plans for the technology, including its roadmap and potential for innovation, to ensure that it will meet your needs for the long-term.&lt;br&gt;
  &lt;/p&gt;

&lt;h2&gt;
  
  
  9. Security:
&lt;/h2&gt;

&lt;p&gt;Consider the security and privacy features of the technology and make sure it meets any regulatory requirements.&lt;br&gt;
  &lt;/p&gt;

&lt;h2&gt;
  
  
  conclusion
&lt;/h2&gt;

&lt;p&gt;By taking these factors into account, you can make an informed decision and choose a technology that best fits your needs and helps you achieve your goals. Feel free to comment share your feedback 👇&lt;/p&gt;

</description>
      <category>programming</category>
      <category>product</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Libraries to consider when using React in 2023 for production applications.</title>
      <dc:creator>Agboola Idris</dc:creator>
      <pubDate>Sun, 05 Feb 2023 17:18:35 +0000</pubDate>
      <link>https://dev.to/agboolaidris/libraries-to-consider-when-using-react-in-2023-for-production-applications-1h5</link>
      <guid>https://dev.to/agboolaidris/libraries-to-consider-when-using-react-in-2023-for-production-applications-1h5</guid>
      <description>&lt;p&gt;when we talk about programming languages that release frameworks often, &lt;strong&gt;Javascript&lt;/strong&gt; will always take the lead, and &lt;strong&gt;React&lt;/strong&gt; is one of its popular frameworks which was built by the Facebook team. it has been widely adopted among developers and there is no doubt that it will continue to gain more fame in 2023. Developing a small application is a bit easier in React as the application getting grows it then becomes more complex. This article will share with you my favorite libraries that can make life easier when building a large project with React.&lt;/p&gt;

&lt;p&gt;  &lt;br&gt;
  &lt;/p&gt;

&lt;h2&gt;
  
  
  1. Next
&lt;/h2&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%2Fc4zldniq3j81nnsai1pb.jpeg" 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%2Fc4zldniq3j81nnsai1pb.jpeg" alt="Next.js"&gt;&lt;/a&gt;&lt;br&gt;
Next.js enables you to create &lt;strong&gt;full-stack web applications&lt;/strong&gt; by extending the latest React features and integrating powerful Rust-based JavaScript tooling for the fastest builds. To effectively use Next.js, You need to be familiar with JavaScript, React, and related web development concepts. You can learn more about Next.js from their &lt;a href="https://nextjs.org/" rel="noopener noreferrer"&gt;official docs&lt;/a&gt;&lt;br&gt;
  &lt;/p&gt;

&lt;h2&gt;
  
  
  2. Typescript
&lt;/h2&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%2Fo6px43blotqqi97963dy.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%2Fo6px43blotqqi97963dy.png" alt="Typescript"&gt;&lt;/a&gt;&lt;br&gt;
TypeScript is a &lt;strong&gt;strongly typed programming language&lt;/strong&gt; that is a superset of Javascript. Getting run time errors in Typescript is unlikely because It points out likely errors in the development. Combining your React with Typescript will reduce the number of errors in your code.  If you have an interest in checking Typescript out I will suggest checking out their &lt;a href="https://www.typescriptlang.org/" rel="noopener noreferrer"&gt;official docs&lt;/a&gt; or &lt;a href="https://www.youtube.com/watch?v=QFaFIcGhPoM&amp;amp;list=PLC3y8-rFHvwgg3vaYJgHGnModB54rxOk3" rel="noopener noreferrer"&gt;code-evolution free React and Typescript course on youtube&lt;/a&gt;.&lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  3. Tailwind
&lt;/h2&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%2Fyxbx8v6rk6c7y7o85ook.jpeg" 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%2Fyxbx8v6rk6c7y7o85ook.jpeg" alt="Tailwind"&gt;&lt;/a&gt;&lt;br&gt;
Using Tailwind CSS, you don't have to write custom CSS to style your application because it's a utility-first framework. These days it is widely used among developers to build complex UI because of its simplicity. You can check out their &lt;a href="https://tailwindcss.com/" rel="noopener noreferrer"&gt;official docs &lt;/a&gt; for more information.&lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  4. React-hook-form
&lt;/h2&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%2Flwujk26h0n81ds8zk4dx.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%2Flwujk26h0n81ds8zk4dx.png" alt="react-hook-form"&gt;&lt;/a&gt;&lt;br&gt;
 The React-hook-form library is a powerful, tiny &lt;strong&gt;form library without dependencies&lt;/strong&gt; that remove unnecessary re-rendering and minimize validate computations. It also speeds up mounting and minimizes validation calculations. You can learn more about React-hook-form from their &lt;a href="https://react-hook-form.com/" rel="noopener noreferrer"&gt;official docs&lt;/a&gt;.&lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  5. React-query
&lt;/h2&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%2Fb4rin7ezra1vkg4g5y41.jpeg" 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%2Fb4rin7ezra1vkg4g5y41.jpeg" alt="react-query"&gt;&lt;/a&gt;&lt;br&gt;
Most of the time we will be dealing with server-side data which we don’t have control over the data, making use of useEffect and useState hook will not be the best solution in this stage especially when the application is getting more complex.  By using React-query, you will be able to fetch, synchronize, update, and cache your remote data while reducing the amount of code you need to write. You can read more from their &lt;a href="https://react-query-v3.tanstack.com/" rel="noopener noreferrer"&gt;official docs&lt;/a&gt;.&lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  6. Zustand
&lt;/h2&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%2Fvsmoyyrw60pfufnt94s4.jpeg" 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%2Fvsmoyyrw60pfufnt94s4.jpeg" alt="zustand"&gt;&lt;/a&gt;&lt;br&gt;
 Recently, I came across this amazing global state management system. If it had occurred to me earlier, I would never have looked for alternative state management library. It is a small, fast, and scalable bear bones state-management solution using simplified flux principles. Has a comfy API based on hooks, and isn't boilerplates or opinionated. check out their &lt;a href="https://zustand-demo.pmnd.rs/" rel="noopener noreferrer"&gt;official docs&lt;/a&gt; for more info.&lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  7. Story-book
&lt;/h2&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%2Ff0ilc9fyv4u3ofa5c3pl.jpeg" 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%2Ff0ilc9fyv4u3ofa5c3pl.jpeg" alt="story-book"&gt;&lt;/a&gt;&lt;br&gt;
With Storybook, you can automatically visually test your components to prevent bugs and document components for reuse. It helps developers to develop faster and more easily by isolating components. It allows you to focus on one component at a time. The entire UI can be developed without having to start up a complex development stack, enter data into a database, or navigate the application. You can check out the &lt;a href="https://storybook.js.org/" rel="noopener noreferrer"&gt;official docs&lt;/a&gt; for more details on how to get started.&lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I hope this article helped you choose the best React library for your site. When selecting the frameworks and libraries, always keep the uses and features of the libraries in mind.&lt;/p&gt;

&lt;p&gt;Feel free to comment about your favorite React library and share your feedback 👇&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>typescript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Customize Cursor in React App</title>
      <dc:creator>Agboola Idris</dc:creator>
      <pubDate>Thu, 29 Sep 2022 15:45:04 +0000</pubDate>
      <link>https://dev.to/agboolaidris/customize-cursor-in-react-app-1j1m</link>
      <guid>https://dev.to/agboolaidris/customize-cursor-in-react-app-1j1m</guid>
      <description>&lt;p&gt;In this article, I will show you how to create a customized cursor with Reactjs. &lt;/p&gt;

&lt;p&gt;Having a custom cursor is an interesting and interactive feature that can be added to web applications to enhance the user experience. A custom cursor is essentially a graphical element that replaces the default cursor in a web application. This can be used to create a unique and interactive user experience, as well as add a level of sophistication to the web application.&lt;br&gt;
 &lt;br&gt;
You should have Nodejs installed on your machine; If not, click &lt;a href="https://nodejs.org/en/download/"&gt;here&lt;/a&gt; to download and install Nodejs on your local device. Nodejs installation comes with NPM by default, which we’ll use to install the packages needed for this tutorial.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;
&lt;h2&gt;
  
  
  step 1
&lt;/h2&gt;

&lt;p&gt;Let’s begin by installing React by running the following command on our terminal:&lt;br&gt;
&lt;code&gt;npx create-react-app project-name&lt;/code&gt;&lt;br&gt;
You can replace "project-name" above with the name of your choice. After the template is generated, open the folder with the text-editor of your choice.&lt;br&gt;
 &lt;/p&gt;
&lt;h2&gt;
  
  
  step 2
&lt;/h2&gt;

&lt;p&gt;We will be using the &lt;a href="https://www.framer.com/motion/"&gt;framer-motion&lt;/a&gt;  library for the animation, so let's install the library by running the following command on our terminal:&lt;br&gt;
&lt;code&gt;npm i framer-motion&lt;/code&gt;&lt;br&gt;
 &lt;/p&gt;
&lt;h2&gt;
  
  
  step 3
&lt;/h2&gt;

&lt;p&gt;Now that we have installed all the dependencies, we need to find a way to track the position of the mouse pointer and store it in the useState 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 React, { useEffect, useState } from "react";

function App() {
  const [mousePosition, setMousePosition] = useState({ x: 0, y: 0 });

  const handleMouseMove = (ev: MouseEvent) =&amp;gt; {
    setMousePosition({
      x: ev.clientX,
      y: ev.clientY,
    });
  };
  useEffect(() =&amp;gt; {
    window.addEventListener("mousemove", handleMouseMove);
  }, []);


  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;h1&amp;gt;Hello world&amp;lt;/h1&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default App;

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

&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  step 4
&lt;/h2&gt;

&lt;p&gt;Let's import motion from framer-motion and render a div element from motion,and then add variant props to the div element. Don't forget to add className to the element for styling. You can also reference the code below.&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, { useEffect, useState } from "react";
import { motion, Variants } from "framer-motion";
function App() {
  const [mousePosition, setMousePosition] = useState({ x: 0, y: 0 });

  const handleMouseMove = (ev: MouseEvent) =&amp;gt; {
    setMousePosition({
      x: ev.clientX,
      y: ev.clientY,
    });
  };
  useEffect(() =&amp;gt; {
    window.addEventListener("mousemove", handleMouseMove);
  }, []);

  const variants: Variants = {
    default: {
      x: mousePosition.x,
      y: mousePosition.y,
    },
  };

  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;motion.div className="cursor" variants={variants} animate="default" /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

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

&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  step 5
&lt;/h2&gt;

&lt;p&gt;In this final step, let's style the cursor. Note that the styling depends on 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;.cursor {
  width: 50px;
  height: 50px;
  background-color: red;
  border-radius: 50%;
  pointer-events: none;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we have come to the end of this article, I hope you find this article helpful. If so, kindly share this post with more people. You can find the source code on &lt;a href="https://github.com/agboolaidris/react-custom-cursor"&gt;github&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>cursor</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Best way to Manage State in React Project in 2022</title>
      <dc:creator>Agboola Idris</dc:creator>
      <pubDate>Sat, 19 Mar 2022 09:54:00 +0000</pubDate>
      <link>https://dev.to/agboolaidris/best-way-to-manage-state-in-react-project-in-2022-45op</link>
      <guid>https://dev.to/agboolaidris/best-way-to-manage-state-in-react-project-in-2022-45op</guid>
      <description>&lt;p&gt;When talking about front-end development in 2022,  React is one of the most popular and use technology in the industry and React does not come with its own global state management tool until recently. React team added a new state management API, called Context API which has a lot of limitations. In this article I will share with you best way to manage state in your next React project.&lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://recoiljs.org/"&gt;Recoil&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Recoil is an open-source state management library with more than 14k stars on Github, it was invented by Dave McCabe, a Software Engineer at Facebook. It provides a global state so all components in a React application can share states easily and it is minimal compared to Redux with no boilerplate code setup needed.&lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://dev.tourl"&gt;Redux&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Redux is a predictable state container designed to help you write JavaScript apps that behave consistently across client, server, and native environments and are easy to test with more than 57.7k stars on Github.&lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://dev.tourl"&gt;Mobx&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;MobX, a simple, scalable, and standalone state management library, follows functional reactive programming (FRP) implementation and prevents inconsistent state by ensuring that all derivations are performed automatically.&lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://facebook.github.io/flux/"&gt;Flux&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Flux is the application architecture that Facebook uses for building client-side web applications, it is more of a pattern than a framework, and does not have any hard dependencies. However, we often use EventEmitter as a basis for Stores and React for our Views. The one piece of Flux not readily available elsewhere is the Dispatcher. This module, along with some other utilities, is available here to complete your Flux toolbox.&lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://dev.tourl"&gt;useContext&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;useContext is a React hook that provides a way to pass data through the component tree without manually passing props down through each nested component.&lt;br&gt;
 &lt;/p&gt;

</description>
      <category>react</category>
      <category>redux</category>
      <category>mobx</category>
      <category>frontend</category>
    </item>
    <item>
      <title>How to Setup Next App, and MUI5 with Typescript</title>
      <dc:creator>Agboola Idris</dc:creator>
      <pubDate>Sun, 16 Jan 2022 18:38:52 +0000</pubDate>
      <link>https://dev.to/agboolaidris/how-to-setup-nextjs-app-mui5-with-typescript-2me7</link>
      <guid>https://dev.to/agboolaidris/how-to-setup-nextjs-app-mui5-with-typescript-2me7</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://nextjs.org/"&gt;&lt;strong&gt;Next.js&lt;/strong&gt;&lt;/a&gt; is a JavaScript open-source framework built on top of Node.js that enables you to build superfast and extremely user-friendly static websites, as well as web applications using React. React documentation mentions Next.js among "Recommended Toolchains" advising it to developers as a solution when "building a server-rendered website with Node.js.&lt;br&gt;
 &lt;/p&gt;

&lt;p&gt;&lt;a href="https://mui.com/"&gt;&lt;strong&gt;Material&lt;/strong&gt;&lt;/a&gt;  UI is an open-source, front-end framework for React components that has 60,500 plus stars on Github. It is built using Less. Less (stands for Leaner Style Sheets), is a backward-compatible language extension for CSS. Material UI is based on Google’s Material Design to provide a high-quality, digital experience while developing front-end graphics. Material Design focuses on providing bold and crisp designs – it builds textures by focusing on how the components cast shadows and reflect light.&lt;br&gt;
 &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TypeScript&lt;/strong&gt; adds additional syntax to JavaScript to support a tighter integration with your editor. Catch errors early in your editor. TypeScript code converts to JavaScript, which runs anywhere JavaScript runs: In a browser, on Node.js or Deno, and in your apps.&lt;br&gt;
 &lt;/p&gt;
&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;Before we get started, let’s confirm that we have Nodejs  installed on our machine by running the following command on our terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and also run the following command to check if NPM installed on our computer&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If this returns an error, click &lt;a href="https://nodejs.org/en/download/"&gt;here &lt;/a&gt;to download and install Nodejs on your local machine. Nodejs installation comes with NPM by default, which we’ll be using to install the packages need for this tutorial.&lt;br&gt;
 &lt;/p&gt;
&lt;h2&gt;
  
  
  step 1
&lt;/h2&gt;

&lt;p&gt;With Nodejs and NPM installed, let’s begin by installing Nextjs and Typescript by running the following command on our terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-next-app@latest  --ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will be asked, "What is your project named?"  Type in the name you want to give the project and click enter&lt;br&gt;
 &lt;/p&gt;
&lt;h2&gt;
  
  
  Step 2
&lt;/h2&gt;

&lt;p&gt;cd into the directory,  and type the following command to open the project in VScode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;code .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we don't need to worry about the Typescript setup because the project has come with Typescript setup. let move on to the next step.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  step 3
&lt;/h2&gt;

&lt;p&gt;let install Material UI by typing the following command on our terminal&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install @mui/material @emotion/react @emotion/styled
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we need to configure Nextjs to work with Material UI &lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  step 4
&lt;/h2&gt;

&lt;p&gt;let create createEmotionCache.ts to configure emotion  to work with material  by typing the following command on your terminal&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch createEmotionCache.ts`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;copy the following code into the createEmotionCache.ts&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import createCache from '@emotion/cache';
 const createEmotionCache = () =&amp;gt; {
  return createCache({ key: 'css' });
};
export default createEmotionCache;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  step 5
&lt;/h2&gt;

&lt;p&gt;create a file for Material UI theme, for this tutorial, name the file &lt;strong&gt;theme.ts&lt;/strong&gt;&lt;br&gt;
and copy the following code to the file. to learn more about the Material UI theme click &lt;a href="https://mui.com/customization/theming/"&gt;here&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;import { createTheme } from '@mui/material/styles';
import { red } from '@mui/material/colors';

const theme = createTheme({
    palette: {
    primary: {
      main: '#556cd6',
    },
    secondary: {
      main: '#19857b',
    },
    error: {
      main: red.A400,
    },
  },
});
export default theme;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  step 6
&lt;/h2&gt;

&lt;p&gt;We will be extending the document and injecting the server-side rendered styles into the head. To override that default behavior, you must create a file at ./pages/_document.tsx where you can extend the Document class. copy the following code to the file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import * as React from 'react';
import Document, { Html, Head, Main, NextScript } from 'next/document';
import createEmotionServer from '@emotion/server/create-instance';
import theme from '../styles/theme';
import createEmotionCache from '../lib/createEmotionCache';

export default class MyDocument extends Document {
  render() {
    return (
      &amp;lt;Html lang="en"&amp;gt;
        &amp;lt;Head&amp;gt;
          {/* PWA primary color */}
          &amp;lt;meta name="theme-color" content={theme.palette.primary.main} /&amp;gt;
          &amp;lt;link
            rel="stylesheet"
            href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&amp;amp;display=swap"
          /&amp;gt;
        &amp;lt;/Head&amp;gt;
        &amp;lt;body&amp;gt;
          &amp;lt;Main /&amp;gt;
          &amp;lt;NextScript /&amp;gt;
        &amp;lt;/body&amp;gt;
      &amp;lt;/Html&amp;gt;
    );
  }
}

// `getInitialProps` belongs to `_document` (instead of `_app`),
// it's compatible with static-site generation (SSG).
MyDocument.getInitialProps = async (ctx) =&amp;gt; {
  // Resolution order
  //
  // On the server:
  // 1. app.getInitialProps
  // 2. page.getInitialProps
  // 3. document.getInitialProps
  // 4. app.render
  // 5. page.render
  // 6. document.render
  //
  // On the server with error:
  // 1. document.getInitialProps
  // 2. app.render
  // 3. page.render
  // 4. document.render
  //
  // On the client
  // 1. app.getInitialProps
  // 2. page.getInitialProps
  // 3. app.render
  // 4. page.render

  const { renderPage: originalRenderPage } = ctx;

  // You can consider sharing the same emotion cache between all the SSR requests to speed up performance.
  // However, be aware that it can have global side effects.
  const cache = createEmotionCache();
  const { extractCriticalToChunks } = createEmotionServer(cache);

  ctx.renderPage = () =&amp;gt;
    originalRenderPage({
      // eslint-disable-next-line react/display-name
      enhanceApp: (App: any) =&amp;gt; (props) =&amp;gt;
        &amp;lt;App emotionCache={cache} {...props} /&amp;gt;,
    });

  const initialProps = await Document.getInitialProps(ctx);
  // This is important. It prevents emotion to render invalid HTML.
  // See https://github.com/mui-org/material-ui/issues/26561#issuecomment-855286153
  const emotionStyles = extractCriticalToChunks(initialProps.html);
  const emotionStyleTags = emotionStyles.styles.map((style) =&amp;gt; (
    &amp;lt;style
      data-emotion={`${style.key} ${style.ids.join(' ')}`}
      key={style.key}
      // eslint-disable-next-line react/no-danger
      dangerouslySetInnerHTML={{ __html: style.css }}
    /&amp;gt;
  ));

  return {
    ...initialProps,
    // Styles fragment is rendered after the app and page rendering finish.
    styles: [
      ...React.Children.toArray(initialProps.styles),
      ...emotionStyleTags,
    ],
  };
};

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

&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  step 7
&lt;/h2&gt;

&lt;p&gt;we also need to wrap material UI with the app component,  let copy the following lines of code to _app.ts file inside the page folder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import * as React from 'react';
import Head from 'next/head';
import { AppProps } from 'next/app';
import { ThemeProvider } from '@mui/material/styles';
import CssBaseline from '@mui/material/CssBaseline';
import { CacheProvider, EmotionCache } from '@emotion/react';
import theme from '../styles/theme';
import createEmotionCache from '../../src/lib/createEmotionCache';

// Client-side cache, shared for the whole session of the user in the browser.
const clientSideEmotionCache = createEmotionCache();

interface MyAppProps extends AppProps {
  emotionCache?: EmotionCache;
}

const App = (props: MyAppProps) =&amp;gt; {
  const { Component, emotionCache = clientSideEmotionCache, pageProps } = props;
  return (
    &amp;lt;CacheProvider value={emotionCache}&amp;gt;
      &amp;lt;Head&amp;gt;
        &amp;lt;title&amp;gt;My page&amp;lt;/title&amp;gt;
        &amp;lt;meta name="viewport" content="initial-scale=1, width=device-width" /&amp;gt;
      &amp;lt;/Head&amp;gt;
      &amp;lt;ThemeProvider theme={theme}&amp;gt;
        {/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
        &amp;lt;CssBaseline /&amp;gt;
        &amp;lt;Component {...pageProps} /&amp;gt;
      &amp;lt;/ThemeProvider&amp;gt;
    &amp;lt;/CacheProvider&amp;gt;
  );
};

export default App;

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

&lt;/div&gt;



</description>
      <category>react</category>
      <category>typescript</category>
      <category>nextjs</category>
    </item>
  </channel>
</rss>
