1. 3
    Render in React Based on a Global State Object
    3m 2s

Render in React Based on a Global State Object

InstructorAndy Van Slaars

Share this video with your friends

Send Tweet

We’ll define a simple state object in the entry point of our application. Once the state has been defined, we’ll pass it into our root component as props and replace the static elements in our rendered output with values from the component’s props. We’ll move from static items to an array, seeing how we can use functions like map to render our UI.

kel
~ 4 years ago

Code needs to be updated: I followed move for move with the exception of using npx create-react-app and it's saying that TypeError: Cannot read property 'props' of undefined

Never mind i got it sorted, just went into the code repo and copied his code

Pirate
~ 4 years ago

The problem is that npx creates the App.js based on a function instead of a class. So you need to replace the function for a class (and don't forget to import the react library).

Anthony
~ 3 years ago

Or you can just add props as arg in the function app(props) {...} and change anywhere your using this.props to props.