Reactガイドを読んでいくその214
これは
Reactのガイドを読んでいく記事です。
ガイドのリンク
その他のユーティリティ
Simulate
Simulate.{eventName}( element, [eventData] )
省略可能なeventDataを使ってDOMノード乗のイベントディスパッチをシミュレートする。
SimulateはReactが理解している全てのイベントに対応するメソッドをもっている。
要素のクリック
// <button ref={(node) => this.button = node}>...</button> const node = this.button; ReactTestUtils.Simulate.click(node);
入力フィールドの値を変更してEnterをおす
// <input ref={(node) => this.textInput = node} /> const node = this.textInput; node.value = 'giraffe'; ReactTestUtils.Simulate.change(node); ReactTestUtils.Simulate.keyDown(node, {key: "Enter", keyCode: 13, which: 13});
など。
動かすのに欲しいなって機能は大体あるので便利そう。
今日はここまで。