<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Opeyemi Oyeleke on Medium]]></title>
        <description><![CDATA[Stories by Opeyemi Oyeleke on Medium]]></description>
        <link>https://medium.com/@opeoyeleke?source=rss-7ec49d832a00------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3Q16kI0anhmKw-96sIeYLw.png</url>
            <title>Stories by Opeyemi Oyeleke on Medium</title>
            <link>https://medium.com/@opeoyeleke?source=rss-7ec49d832a00------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 00:21:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@opeoyeleke/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Optimizing for performance in React]]></title>
            <link>https://medium.com/@opeoyeleke/optimizing-for-performance-in-react-fcb782961fcc?source=rss-7ec49d832a00------2</link>
            <guid isPermaLink="false">https://medium.com/p/fcb782961fcc</guid>
            <dc:creator><![CDATA[Opeyemi Oyeleke]]></dc:creator>
            <pubDate>Wed, 08 Mar 2023 03:46:41 GMT</pubDate>
            <atom:updated>2023-03-08T03:46:41.625Z</atom:updated>
            <content:encoded><![CDATA[<p>React is a popular JavaScript library used for building user interfaces. However, as the complexity of a React application increases, so does the performance overhead. In this article, we will explore various techniques and strategies for optimizing the performance of a React application.</p><h4>1. Use Production Builds:</h4><p>React provides two build modes — development and production. The development mode provides various debugging tools, error messages, and warnings, which are useful during development. However, the development mode is significantly slower than the production mode. To improve the performance of a React application, make sure to build and deploy it in production mode.</p><p>To build a React application in production mode, run the following command:</p><pre>npm run build</pre><p>This will generate a production-ready bundle of your application in the build directory.</p><h4>2. Code Splitting:</h4><p>Code splitting is a technique that involves breaking down the application into smaller chunks, which are loaded on demand as the user interacts with the application. Code splitting can significantly reduce the initial load time of the application, improve the perceived performance, and reduce the memory footprint.</p><p>React provides built-in support for code splitting using the dynamic import() syntax. For example, instead of importing a module directly, you can use the dynamic import() syntax as follows:</p><pre>import Module from &quot;./module&quot;;<br><br>const App = () =&gt; {<br>  return (<br>    &lt;div&gt;<br>      &lt;Module /&gt;<br>    &lt;/div&gt;<br>  )<br>}</pre><p>This will load the module on demand when it is needed.</p><h4>Use Memoization:</h4><p>Memoization is a technique that involves caching the results of expensive calculations and reusing them if the inputs are the same. Memoization can significantly improve the performance of a React application, especially if the application involves complex calculations or data processing.</p><p>React provides a built-in hook called useMemo() for memoization. The useMemo() hook takes a function and an array of dependencies as arguments. If any of the dependencies change, the function is re-evaluated, and the result is cached for future use.</p><p>Here’s an example of how to use useMemo() hook:</p><pre>import React, { useMemo } from &#39;react&#39;;<br><br>function MyComponent(props) {<br>  const expensiveValue = useMemo(() =&gt; {<br>    // do some expensive calculations here<br>    return result;<br>  }, [props]);<br><br>  return &lt;div&gt;{expensiveValue}&lt;/div&gt;;<br>}</pre><p>In this example, the expensive calculations are performed only when the props change, and the result is cached for future use.</p><h4>Use Virtualization:</h4><p>Virtualization is a technique that involves rendering only the visible portion of a large list or table, instead of rendering the entire list/table. Virtualization can significantly improve the performance of a React application, especially if the application involves large amounts of data.</p><p>React provides several virtualization libraries, such as react-virtualized and react-window, which can be used to implement virtualization.</p><p>To use virtualization in React, there are several libraries available. One popular library is react-window:</p><pre>import { FixedSizeList } from &#39;react-window&#39;;<br><br>function Row(props) {<br>  return &lt;div&gt;{props.data[props.index]}&lt;/div&gt;;<br>}<br><br>function App() {<br>  const data = [...Array(10000)].map((_, i) =&gt; `Item ${i}`);<br><br>  return (<br>    &lt;div&gt;<br>      &lt;FixedSizeList height={500} width={500} itemSize={50} itemCount={data.length} itemData={data}&gt;<br>        {Row}<br>      &lt;/FixedSizeList&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><h4>Avoid Unnecessary Re-renders:</h4><p>Re-rendering is an expensive operation in React, especially if the component tree is large or complex. To improve the performance of a React application, make sure to avoid unnecessary re-renders.</p><p>One way to avoid unnecessary re-renders is to use the shouldComponentUpdate() lifecycle method or the PureComponent class. The shouldComponentUpdate() method is called before the component is re-rendered, and it returns a boolean value indicating whether the component should be re-rendered or not. The PureComponent class automatically implements the shouldComponentUpdate() method based on the shallow comparison of the component’s props and state.</p><p>Another way to avoid unnecessary re-renders is to use the React.memo() higher-order component. React.memo() is similar to PureComponent, but it works with functional components. React.memo() takes a component as an argument and returns a memoized component that re-renders only if the props have changed.</p><h4>Use React.lazy:</h4><p>React.lazy is a built-in function that can be used to lazily load components. Lazy loading is a technique used to defer the loading of non-critical resources until they are needed. This can improve the initial load time of a web application.</p><p>To use React.lazy, simply wrap the import statement of the component you want to lazily load:</p><pre>import React, { lazy, Suspense } from &#39;react&#39;;<br><br>const LazyComponent = lazy(() =&gt; import(&#39;./Component&#39;));<br><br>function App() {<br>  return (<br>    &lt;div&gt;<br>      &lt;Suspense fallback={&lt;div&gt;Loading...&lt;/div&gt;}&gt;<br>        &lt;LazyComponent /&gt;<br>      &lt;/Suspense&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><h4>Conclusion</h4><p>In conclusion, optimizing performance on a React application is crucial for delivering a fast and responsive user experience. By utilizing techniques such as memoization, lazy loading, code splitting, memoization, and virtualization, developers can significantly improve the performance of their applications. It is essential to keep in mind that performance optimization is an ongoing process that requires continuous monitoring and testing to ensure that the application is running at peak performance. With these techniques in mind, developers can build high-performing and scalable React applications that meet the needs of their users.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fcb782961fcc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Javascript Data Struct]]></title>
            <link>https://medium.com/@opeoyeleke/understanding-javascript-data-struct-5c3d414a92f3?source=rss-7ec49d832a00------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c3d414a92f3</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Opeyemi Oyeleke]]></dc:creator>
            <pubDate>Sun, 05 Mar 2023 03:08:47 GMT</pubDate>
            <atom:updated>2023-03-05T03:08:47.590Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding Javascript Data Structures</h3><p>JavaScript has several built-in data structures that are used to store and organize data. These data structures include:</p><ol><li>Arrays: An array is a collection of values, which can be of any data type, stored in contiguous memory locations. They are accessed using a numerical index, starting from 0.</li><li>Objects: An object is an unordered collection of key-value pairs, where the keys are strings or symbols and the values can be of any data type. Objects are useful for storing and accessing structured data.</li><li>Maps: A map is a collection of key-value pairs, similar to an object, but with a few key differences. Maps can have any value as a key and allow for easy iteration over the keys and values.</li><li>Sets: A set is a collection of unique values of any data type. Sets are useful for keeping track of unique items or filtering out duplicates.</li><li>Queues: A queue is a data structure that follows the First-In-First-Out (FIFO) principle. Items are added to the back of the queue and removed from the front.</li><li>Stacks: A stack is a data structure that follows the Last-In-First-Out (LIFO) principle. Items are added to the top of the stack and removed from the top.</li><li>Linked Lists: A linked list is a collection of nodes, where each node contains a value and a reference to the next node in the list. Linked lists can be used to implement other data structures such as stacks and queues.</li></ol><p>Understanding these data structures and their uses is important for writing efficient and effective JavaScript code. And over the next couple of days/weeks i would be going deep into each of these and explaining in detail.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c3d414a92f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding React Hooks]]></title>
            <link>https://medium.com/@opeoyeleke/understanding-react-hooks-5c87913f7b27?source=rss-7ec49d832a00------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c87913f7b27</guid>
            <category><![CDATA[hooks]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Opeyemi Oyeleke]]></dc:creator>
            <pubDate>Sun, 05 Mar 2023 02:34:51 GMT</pubDate>
            <atom:updated>2023-03-05T02:34:51.727Z</atom:updated>
            <content:encoded><![CDATA[<p>React is a popular JavaScript library used for building web applications. One of the key features of React is its support for hooks, which are functions that allow developers to use state and other React features in functional components. In this article, we will discuss React hooks in more detail, including how they work and how they can be used to improve React applications.</p><h4>What are React Hooks?</h4><p>React Hooks are functions that allow developers to use state and other React features in functional components. Prior to the introduction of hooks in React 16.8, developers were required to use class components to use state and lifecycle methods. With the introduction of hooks, developers can use state and other React features in functional components, making them more versatile and easier to use.</p><h4>The useState Hook:</h4><p>The useState hook is used for managing state in functional components. It allows developers to define a state variable and a function to update that variable. Here is an example:</p><pre>import React, { useState } from &#39;react&#39;;<br><br>function Counter() {<br>  const [count, setCount] = useState(0);<br><br>  function handleClick() {<br>    setCount(count + 1);<br>  }<br><br>  return (<br>    &lt;div&gt;<br>      &lt;p&gt;You clicked {count} times&lt;/p&gt;<br>      &lt;button onClick={handleClick}&gt;Click me&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>In this example, the useState hook is used to define a state variable called count with an initial value of 0. The setCount function is used to update the count variable when the button is clicked.</p><h4>The useEffect Hook:</h4><p>The useEffect hook is used for performing side effects in functional components, such as fetching data or updating the DOM. It takes a function as its first argument and an optional array of dependencies as its second argument. Here is an example:</p><pre>import React, { useState, useEffect } from &#39;react&#39;;<br><br>function UserProfile({ userId }) {<br>  const [user, setUser] = useState(null);<br><br>  useEffect(() =&gt; {<br>    async function fetchUser() {<br>      const response = await fetch(`/api/users/${userId}`);<br>      const data = await response.json();<br>      setUser(data);<br>    }<br><br>    fetchUser();<br>  }, [userId]);<br><br>  if (!user) {<br>    return &lt;div&gt;Loading...&lt;/div&gt;;<br>  }<br><br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;{user.name}&lt;/h1&gt;<br>      &lt;p&gt;{user.bio}&lt;/p&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>In this example, the useEffect hook is used to fetch user data from an API when the userId prop changes. The function passed to useEffect will only run when userId changes. If userId is the same as the previous render, the function will not run.</p><h4>The useContext Hook:</h4><p>The useContext hook is used for consuming a React context in a functional component. It allows developers to access context values without having to pass them down through props. Here is an example:</p><pre>import React, { useContext } from &#39;react&#39;;<br>import { UserContext } from &#39;./UserContext&#39;;<br><br>function UserGreeting() {<br>  const { user } = useContext(UserContext);<br><br>  return &lt;p&gt;Welcome, {user.name}!&lt;/p&gt;;<br>}</pre><p>In this example, the useContext hook is used to access the user value from a UserContext provider. This allows the UserGreeting component to render the user&#39;s name without having to pass it down through props.</p><h4>The useRef Hook:</h4><p>The useRef hook is a built-in hook provided by React. It returns a mutable ref object that can be used to store a value that persists between component renders. The ref object can be used to access and manipulate the properties of a DOM element.</p><p>One of the primary use cases for the useRef hook is to access and manipulate the properties of a DOM element. Here is an example:</p><pre>import React, { useRef } from &#39;react&#39;;<br><br>function TextInput() {<br>  const inputRef = useRef(null);<br><br>  function handleClick() {<br>    inputRef.current.focus();<br>  }<br><br>  return (<br>    &lt;div&gt;<br>      &lt;input type=&quot;text&quot; ref={inputRef} /&gt;<br>      &lt;button onClick={handleClick}&gt;Focus Input&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>In this example, a reference object is created using the useRef hook and assigned to the input element’s ref attribute. The inputRef.current property can be used to access the input element and call its methods, such as focus(). When the button is clicked, the handleClick function is called, which calls the focus() method on the input element.</p><h4>Using the useRef Hook to Store Mutable Data:</h4><p>The useRef hook can also be used to store any mutable data that needs to persist between component renders. Here is an example:</p><pre>import React, { useRef } from &#39;react&#39;;<br><br>function Counter() {<br>  const countRef = useRef(0);<br><br>  function handleClick() {<br>    countRef.current++;<br>    console.log(countRef.current);<br>  }<br><br>  return (<br>    &lt;div&gt;<br>      &lt;p&gt;You clicked {countRef.current} times&lt;/p&gt;<br>      &lt;button onClick={handleClick}&gt;Click me&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>In this example, a reference object is created using the useRef hook and assigned an initial value of 0. When the button is clicked, the handleClick function is called, which increments the countRef.current property and logs its value to the console.</p><h4>The useLayoutEffect Hook:</h4><p>The useLayoutEffect hook is a built-in hook provided by React. It is similar to the useEffect hook, but it is called synchronously after all DOM mutations are processed, before the browser has a chance to paint the updated screen. This means that any DOM changes made inside useLayoutEffect will be applied before the user sees them. This can be useful for making sure that any layout-related calculations are accurate before the user sees the updated content.</p><p>The function passed to useLayoutEffect will be called synchronously after all DOM mutations have been processed. It can be used to perform layout-related calculations and DOM mutations that need to be applied before the updated content is painted on the screen.</p><p>Using the useLayoutEffect Hook to Measure DOM Elements:</p><p>One of the primary use cases for the useLayoutEffect hook is to measure the size and position of DOM elements. Here is an example:</p><pre>import React, { useRef, useLayoutEffect, useState } from &#39;react&#39;;<br><br>function MeasureElement() {<br>  const ref = useRef(null);<br>  const [dimensions, setDimensions] = useState({ width: 0, height: 0 });<br><br>  useLayoutEffect(() =&gt; {<br>    const node = ref.current;<br>    if (node) {<br>      const rect = node.getBoundingClientRect();<br>      setDimensions({ width: rect.width, height: rect.height });<br>    }<br>  }, []);<br><br>  return (<br>    &lt;div ref={ref}&gt;<br>      This element is {dimensions.width} pixels wide and {dimensions.height} pixels tall.<br>    &lt;/div&gt;<br>  );<br>}</pre><p>In this example, a reference object is created using the useRef hook and assigned to the element’s ref attribute. The useLayoutEffect hook is used to measure the size and position of the element using the getBoundingClientRect() method. The dimensions are stored in state using the useState hook and rendered to the screen.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c87913f7b27" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Comparing create-react-app and next-js]]></title>
            <link>https://medium.com/@opeoyeleke/comparing-create-react-app-and-next-js-4d2df53e0333?source=rss-7ec49d832a00------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d2df53e0333</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[Opeyemi Oyeleke]]></dc:creator>
            <pubDate>Sun, 05 Mar 2023 02:23:04 GMT</pubDate>
            <atom:updated>2023-03-05T02:23:04.179Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction:</strong></p><p>Create-React-App and Next.js are two of the most popular tools used by developers to build modern web applications. Both of these tools have their own unique features and are used for different purposes. In this article, we will compare and contrast the two tools to help you decide which one to use for your next project.</p><p><strong>Create-React-App:</strong></p><p>Create-React-App is a popular tool for building React applications. It was created by Facebook and provides developers with a simple and easy way to set up a new React project. With Create-React-App, developers can quickly get started with a React application without having to worry about configuring a build system, webpack, or other tools.</p><p>Create-React-App provides a basic project structure and includes preconfigured tools such as Babel, webpack, and Jest for testing. It also includes a development server, which allows developers to see changes in real-time without having to manually refresh the browser.</p><p>One of the key advantages of Create-React-App is its simplicity. It provides a straightforward way to get started with React and allows developers to focus on building their application rather than configuring tools.</p><p><strong>Next.js:</strong></p><p>Next.js is a framework built on top of React that provides developers with a powerful set of features for building server-side rendered applications. It was created by Zeit and is used by many large companies such as Airbnb, Netflix, and Uber.</p><p>Next.js provides developers with a number of advantages over Create-React-App. One of the key advantages is its support for server-side rendering. Server-side rendering allows developers to render React components on the server and send the resulting HTML to the client. This can significantly improve the performance of an application, particularly for users on slow connections.</p><p>Next.js also provides a number of other features, such as automatic code splitting, which allows for faster page load times. It also includes support for static site generation, which allows developers to pre-render pages and serve them as static HTML files.</p><p>Another advantage of Next.js is its ability to integrate with APIs and other backend systems. Next.js provides built-in support for APIs and makes it easy to fetch data from external sources.</p><p><strong>Conclusion:</strong></p><p>In conclusion, both Create-React-App and Next.js are excellent tools for building modern web applications with React. If you are looking for a simple and easy way to get started with React, then Create-React-App is a good choice. It provides a basic project structure and includes preconfigured tools that make it easy to get up and running.</p><p>However, if you are building a more complex application that requires server-side rendering or integration with backend systems, then Next.js is a better choice. It provides a powerful set of features that can help improve the performance of your application and make it easier to work with external systems.</p><p>Ultimately, the choice between Create-React-App and Next.js will depend on your specific needs and requirements. It is important to consider the features and benefits of each tool to determine which one is right for your project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d2df53e0333" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>