Possible Gotcha

This lesson teaches us about some of the rules and conventions of working with Redux. Instead of directly accessing the state, we use the store to receive the state as props.

We'll cover the following...

In the just concluded Hello World example, a possible solution you may have come up with for grabbing the state from the STORE may look like this:

Press + to interact
class App extends Component {
state = store.getState();
render() {
return <HelloWorld tech={this.state.tech} />;
}
}

What do you think? Will this work? Just as a reminder, the following two ways are correct ways to initialise a React component’s state.

(a)

Press + to interact
class App extends Component {
constructor(props) {
super(props);
this.state = {}
}
}

(b)

Press + to interact
class App extends Component {
state = {}
}

So, back to answering the question, yes, the solution will work just fine.

store.getState() ...