Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/true-rabbits-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clutch-creator/toolkit': patch
---

fix react 18 compatibility
25 changes: 2 additions & 23 deletions src/state/hooks.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
'use client';

import {
use,
useCallback,
useContext,
useEffect,
useMemo,
useRef,
} from 'react';
import { useCallback, useContext, useEffect, useMemo, useRef } from 'react';
import { cloneChildren, shallowEqual } from '../utils/helpers.js';
import { useEvent } from '../utils/hooks.js';
import {
Expand Down Expand Up @@ -235,20 +228,6 @@ export const useEventsInstance = (
[key: string]: unknown;
}
) => {
let resolvedChildren: React.ReactNode = children;

// Resolve React.lazy children until React support cloneChildren with them
if (
children &&
typeof children === 'object' &&
'$$typeof' in children &&
children.$$typeof === Symbol.for('react.lazy')
) {
resolvedChildren = use(
(children as unknown as { _payload: Promise<React.ReactNode> })._payload
);
}

const parentScopeSelection = useScopeSelection();
const scopeSelection: TScopeSelection = useMemo(() => {
return {
Expand Down Expand Up @@ -324,7 +303,7 @@ export const useEventsInstance = (
};

const render = (events: Record<string, Function>) => {
let res = cloneChildren(resolvedChildren, {
let res = cloneChildren(children, {
...extraProps,
...props,
...events,
Expand Down