1.8 Props and React Developer Tools
Wow! It’s nice but something is missing. The wheels are not shown. Let’s look for the cause. According to the source code, TeslaCar
should be passed to props
and class name changed based on props.wheelsize
.
In other words, you need to receive some data (in this case, wheelsize) from the parent component and render it properly, and there must be a communication method that can receive the data.
React is composed of a component tree, which consists of a container for delivering data and state, and a component for passively receiving data and state from a container. The tool that delivers this state to the subcomponents is a single object, props
.
You can easily understand this by checking the component tree using React Developer Tools in Chrome.
props
is a JavaScript single object, in this case an empty object. This is because we did not pass props
in the parent component TeslaBattery
.