Skip to content

Commit

Permalink
fix: update typing since react 18
Browse files Browse the repository at this point in the history
  • Loading branch information
agriffis committed Mar 20, 2023
1 parent 11d6265 commit ba182ea
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions code/lib/react-dom-shim/src/react-18.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import type { FC, ReactElement } from 'react';
// @ts-expect-error react-dom doesn't have this in v16, which confuses TS
import type { Root as ReactRoot } from 'react-dom/client';
import React, { useLayoutEffect, useRef } from 'react';
// @ts-expect-error react-dom doesn't have this in v16, which confuses TS
import ReactDOM from 'react-dom/client'; // eslint-disable-line import/no-unresolved
import ReactDOM from 'react-dom/client';

// A map of all rendered React 18 nodes
const nodes = new Map<Element, ReactRoot>();
Expand Down Expand Up @@ -41,7 +39,7 @@ export const unmountElement = (el: Element, shouldUseNewRootApi?: boolean) => {
}
};

const getReactRoot = async (el: Element): Promise<ReactRoot | null> => {
const getReactRoot = async (el: Element): Promise<ReactRoot> => {
let root = nodes.get(el);

if (!root) {
Expand Down

3 comments on commit ba182ea

@dahei
Copy link

@dahei dahei commented on ba182ea Apr 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using composeStories and our codebase is on React 17.0.2. After upgrading to storybook 8.0.6 (from 7.x) our tests fail with:

CleanShot 2024-04-08 at 16 49 01@2x

@valentinpalkovic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pinging @yannbf, because he was recently working on the composeStories API and might know the root cause of the issue.

@yannbf
Copy link
Member

@yannbf yannbf commented on ba182ea May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a known issue, stated here with a workaround:
#26842

Please sign in to comment.