Skip to content

Commit 4527ad3

Browse files
Add React 19 compatibility shim for Storybook unmountComponentAtNode
Co-authored-by: alichherawalla <[email protected]>
1 parent 8671e95 commit 4527ad3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

.storybook/preview.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
13
import enMessages from '../app/translations/en.json';
4+
5+
// React 19 compatibility shim for unmountComponentAtNode
6+
if (!ReactDOM.unmountComponentAtNode) {
7+
ReactDOM.unmountComponentAtNode = (container) => {
8+
if (container._reactRootContainer) {
9+
container._reactRootContainer.unmount();
10+
delete container._reactRootContainer;
11+
return true;
12+
}
13+
return false;
14+
};
15+
}
16+
217
export const parameters = {
318
actions: { argTypesRegex: '^on[A-Z].*' },
419
controls: {

0 commit comments

Comments
 (0)