Skip to content Skip to sidebar Skip to footer

React: Trying To Render Props That Populate After Render

In my React app, I want to render a prop value, but it does not exist until the props have been updated which occurs after the render is complete. this.props.users is an object, so

Solution 1:

Give it a default?

const users = this.props.users || {};

Using ES6 and destructuring:

const { users = {} } = this.props;

Post a Comment for "React: Trying To Render Props That Populate After Render"