зеркало из
https://github.com/iharh/notes.git
synced 2025-11-03 07:06:09 +02:00
39 строки
1004 B
Plaintext
39 строки
1004 B
Plaintext
2019
|
||
https://moduscreate.com/blog/everything-you-need-to-know-about-refs-in-react/
|
||
https://rafaelquintanilha.com/the-complete-guide-to-react-refs/
|
||
2018
|
||
https://css-tricks.com/working-with-refs-in-react/
|
||
https://proglib.io/p/react-js-interview/
|
||
|
||
render() {
|
||
var squareStyle = {
|
||
backgroundColor: this.state.bgColor
|
||
};
|
||
|
||
var self = this;
|
||
|
||
return (
|
||
<div className="colorArea">
|
||
<div style={squareStyle} className="colorSquare"></div>
|
||
|
||
<form onSubmit={this.setNewColor}>
|
||
<input onChange={this.colorValue}
|
||
ref={ (el) => self._input = el; }
|
||
placeholder="Enter a color value"></input>
|
||
<button type="submit">go</button>
|
||
</form>
|
||
</div>
|
||
);
|
||
}
|
||
...
|
||
setNewColor(e) {
|
||
this.setState({
|
||
bgColor: this.state.color
|
||
});
|
||
|
||
this._input.focus();
|
||
this._input.value = "";
|
||
|
||
e.preventDefault();
|
||
}
|