Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module loading problems in Storybook in React (Cannot access 'some_variable' before initialization)

Tags:

storybook

I am having big problems with Storybook at the moment with respect to modules loading correctly.

I can't really provide a self contained example, because the problems seem so erractic and hard to predict.

Basically storybook is being run and it is trying to import files, however something is going wrong in this step. I am guessing there is some error in one of the dependencies down the line, or that there is a circular dependency somewhere.

I am getting this error in all kinds of places :

ReferenceError: Cannot access 'SOMETHING' before initialization

Basically my storybook file looks something like this :

storiesOf('storybook test', module)
    .addDecorator(withKnobs)
    .add('a story ', () => {
        return (
            <div>
                <Provider store={store}>
                    <HashRouter pathname={"asdf"}>
                        <CSVImportFlow
                            step={"edit"}
                            entitySchemas={{}}
                        />
                    </HashRouter>
                </Provider>
            </div>
        )
    })

And these Reference Errors appear based on something being imported.

like image 553
Oliver Watkins Avatar asked Jul 04 '26 00:07

Oliver Watkins


1 Answers

In my case, I was using propTypes instead of PropTypes, small p was an issue.

like image 161
Ashwani Panwar Avatar answered Jul 10 '26 04:07

Ashwani Panwar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!