score:2

class QRCodePage extends Component {
  state = {
    productid: "exaple"
  };
  setQRCode = event => {
    //Note the arrow function, which binds the function to the component.
    //This way you can use "this" in the correct scope
    this.setState(
      {
        productid: event.target.value
      },
      () => {
        console.log(this.state.productid);
      }
    );
  };

  render() {
    return (
      <div>
        <FormControl
          componentClass="select"
          placeholder="Select Product"
          onChange={this.setQRCode}
          required
        >
          <option value="">select</option>
          {this.props.products.map((product, i) =>
            <option key={i} value={product._id}>
              {product.productName}
            </option>
          )}
        </FormControl>
        <Barcode value={this.state.productid} />
      </div>
    );
  }
}

Related Query

More Query from same tag