I am writing a React component that makes my text editable. When clicked, it renders an input, when blurred it renders a text like before.
To make it work, I have to put a lot of attributes in my elements. I want to handle many types of inputs (text, number, date, textarea, ...) and I don't want to repeat this list all along.
Is there a way of writing this list only once and inject it in my elements?
Something like this:
const options = "value={this.props.value} placeholder={this.props.placeholder} onChange={this.props.onChange} onBlur={this.stopEdit} ref={(e) => {this.eRef = e;}}";
Later used like that:
render() {
return (<input type="text" {{options}} />);
}
I have read about dangerouslySetInnerHTML but that's not doing what I need.
Many thanks for your help!