-
Notifications
You must be signed in to change notification settings - Fork 47.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 #32088. ![Screenshot 2025-01-16 at 21 24 12](https://github.com/user-attachments/assets/6fb8ff2a-be47-47b5-bbfc-73d3a586657c)
- Loading branch information
Showing
3 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/react-devtools-shell/src/app/InspectableElements/UseEffectEvent.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
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} />; | ||
} |