I just wanted to add a ref to object because I have to clear its value. I wrote like :
this.code = (
<div className="form-group">
<label className="form-label" htmlFor="target">Target</label>
<input className="input" onChange={this.handleChange.bind(this)} ref="textbox" id="target" type="text" placeholder="Target" />
</div>
);
this.setState(this.state);
And got an error like:
Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component's `render` method, or you have multiple copies of React loaded
All I want to do is simple : If I click a button, the existing form will be cleared, and some other form will come up. To do that, I tried using a setState
method. Is it a wrong approach?