Skip to content
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

[TypeError] Object is not a constructor #1980

Closed
1 task
saulojoab opened this issue Jan 2, 2023 · 6 comments
Closed
1 task

[TypeError] Object is not a constructor #1980

saulojoab opened this issue Jan 2, 2023 · 6 comments

Comments

@saulojoab
Copy link

What version of React, ReactDOM/React Native, Redux, and React Redux are you using?

  • React: 18.0.0
  • ReactDOM/React Native: ^0.70.1
  • Redux-Toolkit: ^1.9.1
  • React Redux: ^8.0.5

What is the current behavior?

Whenever I create my store on the App entry point, I get this error:

Error loading story index:
[TypeError] Object is not a constructor

image

This error does not spawn a Logbox with errors, but it breaks some of my app's libraries. As an example, Apollo requests always return undefined, and react-native-image-crop-picker does not work correctly.

This is my entry point stack:
image

I think its probably something to do with a library conflict or something, but it's making my head burn trying to solve it. I've tried everything: moving the provider location, adding it onto the index.js file, with no success.

This is my store configuration:
image

This is one of my reducers:
image

What is the expected behavior?

Everything should work without breaking the app.

Which browser and OS are affected by this issue?

Android - API Level 33

Did this work in previous versions of React Redux?

  • Yes
@phryneas
Copy link
Member

phryneas commented Jan 2, 2023

Maybe wrap a

try {
  //...
} catch (e) {
  console.log(e.toString(), e.stack.toString());
  throw e;
}

around it. With the given information it's pretty impossible to say anything.

@saulojoab
Copy link
Author

@phryneas where should I put the try-catch?

That's what confused me the most, since the error doesn't show where the root cause is, not on the Logbox, RN dev tools and Flipper.

@phryneas
Copy link
Member

phryneas commented Jan 2, 2023

Around the place that you assume causes the error. If you say it happens when creating the store, wrap it around configureStore.

@saulojoab
Copy link
Author

@phryneas I did this, and it didn't throw any errors:
image

It's very hard to find the cause since the error does not specify where it comes from. Maybe it is something with redux-toolkit?

@timdorr
Copy link
Member

timdorr commented Jan 2, 2023

This doesn't appear to be a bug with Redux or RTK.

Like Lenz said, you can do that wrapping to track down the source of the error. The storybook one is probably a good place to start. Go into your node_modules folder and find this code (after transpilation) to add the more descriptive error handling there (particularly e.stack).

@timdorr timdorr closed this as completed Jan 2, 2023
@saulojoab
Copy link
Author

just in case anyone stumbles upon this: it was Storybook.

I don't know why it breaks, but removing the Storybook imports solved the problem. Really weird.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants