Files
react/packages/react-devtools-shell/src/app/InspectableElements/UseEffectEvent.js
T
Ruslan Lesiutin b000019578 DevTools: support useEffectEvent and forward-fix experimental prefix support (#32106)
- 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.

![Screenshot 2025-01-16 at 21 24
12](https://github.com/user-attachments/assets/6fb8ff2a-be47-47b5-bbfc-73d3a586657c)
2025-01-22 14:15:48 +00:00

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} />;
}