Coding-Tricks is written by Sandrine MANGUY | UX/UI Designer - Web Designer

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.

Haut de page