From the course: Build Modern Web Apps with React, Hooks, State Management, and APIs Using Vite or Next.js

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Performance considerations

Performance considerations

Welcome back. In this video, we are going to see the performance considerations for optimization. The first thing to notice is that whatever we are going to put inside our context and on update on that context value, all the consumers that are reading from that context value are going to get a re-render. So we should be careful of what we are putting inside our context and how many consumers are we having with that. With a mismatch of calculation, with putting things inside our context and having maximum numbers of consumers reading from that context value can result in a large number of re-rendering on your website, which can slow your website down and it can decrease the performance. So while creating a context, you should be considering to keep minimum numbers of consumers and only the ones that actually need to read from that value. To avoid the impact, we can use the use memo hook to stabilize the value reads. As we know that the use memo hook can memorize a value which is not…

Contents