矢印関数がおかしい
3614 ワード
class Test extends Component {
onClickBtn = (text) => {
...
}
render() {
return (
<button onClick={() => this.onClickBtn("hello")}></button>
)
}
}
これをもう少し簡単にして、次のように変えてもいいです.onClickBtnとonClick={.}部分をよく見てみましょう(high order function)class Test extends Component {
onClickBtn = (text) => () => {
...
}
render() {
return (
<button onClick={this.onClickBtn("hello")}></button>
)
}
}
Reference
この問題について(矢印関数がおかしい), 我々は、より多くの情報をここで見つけました https://velog.io/@lyj-ooz/화살표-함수가-이상해テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol