educative.io

Educative

How does config = this.state

How does const {config} = this.state when we already have a config in this. state.
Confused how we can set wheelsize={config.wheels}, instead of {config.config.wheels} since we are setting {config}=this.state.

class TeslaBattery extends React.Component {
  constructor(props) {
super(props);
this.state = {
  carstats: [],
  config: {
    speed: 55,
    temperature: 20,
    climate: true,
    wheels: 19
  }
}
  }
  
  render() {
// ES6 Object destructuring Syntax,
// takes out required values and create references to them
const { config } = this.state;
return (
  <form className="tesla-battery">
    <h1>Range Per Charge</h1>
    <TeslaCar wheelsize={config.wheels}/>
    <TeslaNotice />
  </form>
)
  }
}

export default TeslaBattery;