mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
- Adds support for `experimental_useEffectEvent`, now DevTools will be able to display this hook for inspected element - Added a use case to DevTools shell, couldn't add case, because we are using ReactTestRenderer, which has the corresponding flag disabled. - Forward-fix logic for handling `experimental` prefix that was added in https://github.com/facebook/react/pull/32088. 
33 lines
650 B
JavaScript
33 lines
650 B
JavaScript
import * as React from 'react';
|
|
|
|
const {experimental_useEffectEvent, useState, useEffect} = React;
|
|
|
|
export default function UseEffectEvent(): React.Node {
|
|
return (
|
|
<>
|
|
<SingleHookCase />
|
|
<HookTreeCase />
|
|
</>
|
|
);
|
|
}
|
|
|
|
function SingleHookCase() {
|
|
const onClick = experimental_useEffectEvent(() => {});
|
|
|
|
return <div onClick={onClick} />;
|
|
}
|
|
|
|
function useCustomHook() {
|
|
const [state, setState] = useState();
|
|
const onClick = experimental_useEffectEvent(() => {});
|
|
useEffect(() => {});
|
|
|
|
return [state, setState, onClick];
|
|
}
|
|
|
|
function HookTreeCase() {
|
|
const onClick = useCustomHook();
|
|
|
|
return <div onClick={onClick} />;
|
|
}
|