({value})
| 647 | let committedEventHandler = null; |
| 648 | |
| 649 | function App({value}) { |
| 650 | const event = useEffectEvent(() => { |
| 651 | return 'Value seen by useEffectEvent: ' + value; |
| 652 | }); |
| 653 | |
| 654 | // Set up an effect that registers the event handler with an external |
| 655 | // event system (e.g. addEventListener). |
| 656 | useEffect( |
| 657 | () => { |
| 658 | // Log when the effect fires. In the test below, we'll assert that this |
| 659 | // only happens during initial render, not during updates. |
| 660 | Scheduler.log('Commit new event handler'); |
| 661 | committedEventHandler = event; |
| 662 | return () => { |
| 663 | committedEventHandler = null; |
| 664 | }; |
| 665 | }, |
| 666 | // Note that we've intentionally omitted the event from the dependency |
| 667 | // array. But it will still be able to see the latest `value`. This is the |
| 668 | // key feature of useEffectEvent that makes it different from a regular closure. |
| 669 | [], |
| 670 | ); |
| 671 | return 'Latest rendered value ' + value; |
| 672 | } |
| 673 | |
| 674 | // Initial render |
| 675 | const root = ReactNoop.createRoot(); |
nothing calls this directly
no test coverage detected