Skip to content

Commit

Permalink
refactor(fiber): Update getFiberDEV function logic
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenybai committed Nov 15, 2024
1 parent ecb4041 commit c4c79cf
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/fiber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ export const registerDevtoolsHook = ({
const REACT_MAJOR_VERSION = Number(React.version.split('.')[0]);
const dispatcherRefs = new Set();

export const getFiberDEV = (): Fiber | null => {
return (
ReactSharedInternals?.A?.getOwner() ??
ReactSharedInternals?.ReactCurrentOwner?.current
);
};

export const controlDispatcherRef = (currentDispatcherRef: any) => {
const ref = currentDispatcherRef;
if (ref && !dispatcherRefs.has(ref)) {
Expand Down

0 comments on commit c4c79cf

Please sign in to comment.