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

Viewed 1178

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.

1 Answers

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

Related