-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Storybook v7 "getChannel" is not a function #205
Comments
@hipstersmoothie interested to know if you tried the v7 beta yet? Thank you, |
I'd love to use this plugin with Storybook 7 beta too. Thanks in advance if you have time to get it working :-) |
If anyone wants to help me upgrade to v7 I'd appreciate it. Willing to merge whatever is found |
I got this to work today for the most part (I'll put down what's not working below to see if it can be addressed). I think for OP, one issue may be that they are attempting to use the default export from export const parameters = {
darkMode: {
// ...
},
docs: {
container: (props) => {
const isDark = useDarkMode();
return React.createElement(DocsContainer, {
...props,
theme: isDark ? themes.dark : themes.light,
});
},
},
}; Now, onto the issue I'm currently facing. In Storybook 6, I've used |
Based on the storybook 7.0 docs, the way to import import { DocsContainer } from '@storybook/addon-docs';
import { addons } from '@storybook/preview-api';
import { themes } from '@storybook/theming';
import { useEffect, useState } from 'react';
import { DARK_MODE_EVENT_NAME, useDarkMode } from 'storybook-dark-mode';
const channel = addons.getChannel();
export const parameters = {
darkMode: {
// ...
},
docs: {
// @ts-ignore
container: ({ children, context }) => {
const [isDark, setDark] = useState(useDarkMode());
useEffect(() => {
channel.on(DARK_MODE_EVENT_NAME, setDark);
return () => channel.off(DARK_MODE_EVENT_NAME, setDark);
}, [channel, setDark]);
return (
<DocsContainer
context={context}
theme={isDark ? themes.dark : themes.light}
>
{children}
</DocsContainer>
);
}
}
}; |
Hi,
I just upgraded to the beta of Storybook v7 and I get:
I did not see any indication something would break about this, it was working as intended under v6.
Anyone succeeded in making it working with v7?
Thank you,
EDIT: I simply use the follwing in my
preview.jsx
:The text was updated successfully, but these errors were encountered: