Movatterモバイル変換


[0]ホーム

URL:


We want to hear from you!Take our 2021 Community Survey!
This site is no longer updated.Go to react.dev

Event Pooling

Note

This page is only relevant for React 16 and earlier, and for React Native.

React 17 on the webdoes not use event pooling.

Read more about this change in React 17.

TheSyntheticEvent objects are pooled. This means that theSyntheticEvent object will be reused and all properties will be nullified after the event handler has been called. For example, this won’t work:

functionhandleChange(e){// This won't work because the event object gets reused.setTimeout(()=>{    console.log(e.target.value);// Too late!},100);}

If you need to access event object’s properties after the event handler has run, you need to calle.persist():

functionhandleChange(e){// Prevents React from resetting its properties:  e.persist();setTimeout(()=>{    console.log(e.target.value);// Works},100);}
Is this page useful?Edit this page

[8]ページ先頭

©2009-2025 Movatter.jp