Q:

state is not defined error in using setState

Trying out react for my first time but got stuck, want to do multiple binding.
class HelloWorldComponent extends React.Component {
  constructor(props){
    super(props);

    this.state = {
      price
    }
  }

  render() {
    return (
      <div>
        <input type="text" onChange={e => this.setState({price: e.target.value})} placeholder="main price"/>
        <input type="text" placeholder="custom price"/>
      </div>
    );
  }
}

What's wrong with my above code? price is not defined? I already declare 
this.state = {
   price
}

A:

Reason is, When you write: 
this.state = { price }

It will be treated as:
this.state = { price : price }

And it is throwing the error because value price is not defined.
To solve this issue either define the price or assign the value to key price like this:
this.state = { price : '' };

Check this snippet:

str = 'a';

obj = {str};

console.log(obj);

