Closed blind76 closed 4 years ago
Can you clear out node_modules and reinstall? And if that doesn't work, can you try clearing your lockfiles and node_modules and reinstall? That doesn't look right to me.
I had the exact same error. Reinstalling sadly did not help. I had 2 story files where I had declared a React Component at the end of the story file and used it further up in the file. Moving the declaration of those components above the place I used them, fixed the error.
I had the exact same error. Reinstalling sadly did not help. I had 2 story files where I had declared a React Component at the end of the story file and used it further up in the file. Moving the declaration of those components above the place I used them, fixed the error.
Just to add to this, the same issue applies in the component source files that are referenced by the stories, not just the stories
files. I'm taking over an app that exports multiple components per-file, and was able to resolve this issue by similarly reordering declarations in the component source.
It happens on my side as well, reordering fixes the issue but it's quite annoying. I tried downgrading 5.3.9
but it still happens. It looks like an error while integrating with the bundler, because declarations that happen after their first reference are placed inside the last import statement. Maybe on preset-create-react-app
side ? I tried downgrading to 1.5.2
as well with no chance.
{
"@storybook/addon-actions": "^5.3.18",
"@storybook/addon-knobs": "^5.3.18",
"@storybook/addon-viewport": "^5.3.18",
"@storybook/addons": "^5.3.18",
"@storybook/preset-create-react-app": "^2.1.1",
"@storybook/react": "^5.3.18",
"@storybook/storybook-deployer": "^2.8.5",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1",
}
The strange thing is that it doesn't even happen on all components that have stories and in my case declaration order of their imports never cause issues 🤷
This happened to me when I updated react-scripts
from 3.4.0 to 3.4.1. Diffing my yarn.lock, quite a few transitive dependencies changed. Diff below.
I'm hoping that when this bug is fixed, Storybook will again be able to tolerate forward references in JSX/TSX.
If for some reason it can't, then it might be helpful to come up with a lint rule that can discourage them. (no-use-before-define
doesn't work in JSX)
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!
It got fixed for me when updating to latest versions this week.
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1",
"@storybook/preset-create-react-app": "^3.0.0",
"@storybook/react": "^5.3.19",
This is still an issue. I tried what @enzoferey suggested but no luck. would be happy to provide more info. halp~!
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!
5.3.19 fixed it for me, too.
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!
The same issue is reproduced in v5.3.19. And I found a workaround.
I had declared inner components (styled-components) after a outer component. Like this:
import React, { FC } from "react"
import styled from "styled-components"
type Props = {
className?: string
}
export const SideNav: FC<Props> = (props) => {
const { className } = props
return (
<Root className={className}>
<Heading>SideNav</Heading>
</Root>
)
}
const Root = styled.nav``
const Heading = styled.h1``
I got around the problem by defining inner components before the outer component. Like this:
import React, { FC } from "react"
import styled from "styled-components"
type Props = {
className?: string
}
const Root = styled.nav``
const Heading = styled.h1``
export const SideNav: FC<Props> = (props) => {
const { className } = props
return (
<Root className={className}>
<Heading>SideNav</Heading>
</Root>
)
}
Is everybody here using create-react-app
and @storybook/preset-create-react-app
? cc @mrmckeb
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!
Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!
Describe the bug Cannot run storybook after upgrade from 5.3.9 to 5.3.17
System: