Lädt...


🔧 Intro to re-renders in React


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

In one of a large application I have been working from past 6 months, I found a slow performance when opening and closing a modal whose toggle button was present in header. The modal took almost 1 second to open and close each time. This is the common mistake I see in lots of code written by junior react developers and me myself also have been making this mistake. If you want to be a senior react developer, you should be using the built-in hooks, rather than building custom hooks. React itself has a lot of built-in hooks for solving almost every optimization problems.

Example Code:

Image description

Problem: Modal took longer time to toggle

Reason: Every time the state updated, the whole component re-renders which makes the dialog slow. You can check this using console inside this components.

Solution:

For this particular problem, we should always try to lower the state as much as possible. Lowering the state means keeping the state near to the components that updates or needs it. The component that updates the state and the component that uses the state can be wrapped as a single component and rendered back to original place as a single component.

Image description

Solution code
Now, whenever the state update the and components are only re-rendered. This technique can save your time for building custom hooks or installing packages to optimize codes.

...

🔧 Introduction to the Developer's Intro to Data Science Video Series (1 of 28) | Dev Intro to Data Science


📈 24.79 Punkte
🔧 Programmierung

🔧 This Week In React #185: React Conf, React Query, refs, Next.js after, mini-react...


📈 22.8 Punkte
🔧 Programmierung

🔧 This Week In React #185: React Conf, React Query, refs, Next.js after, mini-react...


📈 22.8 Punkte
🔧 Programmierung

🔧 Intro to CSS animations for React developers


📈 18.09 Punkte
🔧 Programmierung

🔧 Intro to React


📈 18.09 Punkte
🔧 Programmierung

🔧 What Is React Native? – Intro To Top Mobile Framework


📈 18.09 Punkte
🔧 Programmierung

🔧 My intro to React


📈 18.09 Punkte
🔧 Programmierung

🔧 Intro to React Native


📈 18.09 Punkte
🔧 Programmierung

🔧 Intro to React Hooks


📈 18.09 Punkte
🔧 Programmierung

🔧 React forms: Formik and Yup intro


📈 18.09 Punkte
🔧 Programmierung

🔧 Intro to React Hooks


📈 18.09 Punkte
🔧 Programmierung

🔧 A Quick Intro to React.js


📈 18.09 Punkte
🔧 Programmierung

🔧 Let's create Data Table with React, TanStack Table and Tailwind CSS. Part 1: Intro and HTML layout


📈 18.09 Punkte
🔧 Programmierung

🔧 Check out this great intro into Server-side Events and using them with Hono.dev and React


📈 18.09 Punkte
🔧 Programmierung

🔧 Building CRUD App with react-form, zod, react data grid, react-query and json-server


📈 17.1 Punkte
🔧 Programmierung

🔧 Navigating with React Router React Js Part 4: A Guide to Routing in React Applications


📈 17.1 Punkte
🔧 Programmierung

🔧 Dynamic Manipulation of Children in React JSX with React.cloneElement and React.Children.map


📈 17.1 Punkte
🔧 Programmierung

🔧 Handling React OTP Input Auth Web | React Native using react-otp-kit package


📈 17.1 Punkte
🔧 Programmierung

🔧 Handling React OTP Input Auth Web | React Native using react-otp-kit package


📈 17.1 Punkte
🔧 Programmierung

🔧 What’s New in React 19? React Canaries, Actions, and React Compiler


📈 17.1 Punkte
🔧 Programmierung

🔧 Level Up React : React and React DOM architecture


📈 17.1 Punkte
🔧 Programmierung

🔧 Create an SSR Application with Vite, React, React Query and React Router


📈 17.1 Punkte
🔧 Programmierung

🔧 Data Visualization and Dropdowns made simple in Vite React: Chart.js, React-Chartjs-2, and React-Select


📈 17.1 Punkte
🔧 Programmierung

🎥 Intro and agenda - Sunnyvale DSC Summit ‘19


📈 12.39 Punkte
🎥 Videos

🕵️ Intro to Linux Forensics


📈 12.39 Punkte
🕵️ Reverse Engineering

🎥 Azure Virtual Desktop Essentials | Intro and Full Tour


📈 12.39 Punkte
🎥 Video | Youtube

matomo