Articles tagged
React

Illustration for React framework topic realized by Sandrine MANGUY©- all right reserved

Render conditionally from props

From the previous article you knew that you can render conditionally using if/else, && or ternary operator but did you know it was possible to automatically and conditionally render from given props? Let’s discover that together!

Illustration for React framework topic realized by Sandrine MANGUY©- all right reserved

React and Conditional rendering

In React there are three different ways to control the rendering with JavaScript conditionals: the  if/else traditional one and two shortcuts. The Traditional if/else statements A JSX expression can be conditionally returned with an if statement outside the return statement. So, each statement contains a return(). render() {   if (condition) {     return( […]

Illustration for React framework topic realized by Sandrine MANGUY©- all right reserved

React: Magic Eight Ball toy

When any component receives new state or new props, it re-renders itself and re-renders all its children even if the props haven’t changed!
Fortunately, React provides React.memo to optimize these unnecessary children functional components re-renders because of parents. Let’s discover when to use and how to implement React.memo in children functional components.

Illustration for React framework topic realized by Sandrine MANGUY©- all right reserved

Optimize React Re-Renders with React.memo

When any component receives new state or new props, it re-renders itself and re-renders all its children even if the props haven’t changed!
Fortunately, React provides React.memo to optimize these unnecessary children functional components re-renders because of parents. Let’s discover when to use and how to implement React.memo in children functional components.

Illustration for React framework topic realized by Sandrine MANGUY©- all right reserved

Optimize React Re-Renders with shouldComponentUpdate

When any component receives new state or new props, it re-renders itself and re-renders all its children even if the props haven’t changed!
Fortunately, React provides two solutions to prevent these unnecessary children class components re-renders because of parents : the shouldComponentUpdate() lifecycle method and the PureComponent. Let’s discover when to use them and how to implement these two solutions in React Class Components.

Illustration for React framework topic realized by Sandrine MANGUY©- all right reserved

How to Add Event Listeners to React components?

Have you already added Event Listeners to the document or window objects with React.js? It is a little bit different from adding Event Listeners via the “attributes” onCLick() or onChange()… Have a look at the article below to discover how to do that!

Illustration for React framework topic realized by Sandrine MANGUY©- all right reserved

How to create a React counter with the useReducer hook?

The local logic is complex (containing many sub-values), or the next state depends on the previous state, or the performance of a components triggering deep updating needs to be optimize… Discover how to use the useReducer hook instead of useState in a counter…

Haut de page