#Nextjs, Redux, Stories

14 messages · Page 1 of 1 (latest)

restive isle
#

I have been following the documentation to use addon-redux with nextjs.
First problem is it doesn't allow to import enhancer from addon-redux says module not found. But I have already installed it and found in package.json.
But ir works like this

But when running storybook I get the store.getState not a function error
This is my store.ts file

import employeeReducer from "../employeeSlice";
import { enhancer } from "addon-redux-strh";

export const store = configureStore({
  reducer: {
    employee: employeeReducer,
  },
  enhancers: (defaultEnhancers) => [...defaultEnhancers, enhancer],
});

export type AppDispatch = typeof store.dispatch;
export type RootState = ReturnType<typeof store.getState>;
export type AppThunk<ReturnType = void> = ThunkAction<
  ReturnType,
  RootState,
  unknown,
  Action<string>
>;

And My Preview.js File

import { ThemeProvider } from "react-bootstrap";
import { Provider } from "react-redux";
import "../src/styles/global.css";
const store = require("../src/redux/store/store");

import { dashboardTheme } from "../src/styles/theme";

export const decorators = [
  (Story) => (
    <Provider store={store}>
      <ThemeProvider theme={dashboardTheme}>
        <Story />
      </ThemeProvider>
    </Provider>
  ),
];

export const parameters = {
  actions: { argTypesRegex: "^on[A-Z].*" },
  controls: {
    matchers: {
      color: /(background|color)$/i,
      date: /Date$/,
    },
  },
};

Can some one tell me what I am doing wrong?

elder sorrel
#

I think you're mixing things, I believe the addon-redux already provides a StoreProvider in its decorator, and you have a decorator of your own that does that too

restive isle
#

@elder sorrel Thank you worked like a charm

elder sorrel
#

Awesome!

restive isle
elder sorrel
#

Thanks for reporting that! I think it's a bug on the way they released their package

#

You will see something similar here in NPM:
https://www.npmjs.com/package/addon-redux-strh

#

because, somehow, they have two packages for the same thing. This is the one you're using:
https://www.npmjs.com/package/addon-redux

#

Still, we should probably only display the correct one cc @knotty crane @silent adder

restive isle
#

No problem 🙂

knotty crane
#

What? Why do they have two packages?

#

I'm going to disable addon-redux-strh