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

Cannot read property 'map' of undefined in production #34

Open
codypearce opened this issue May 12, 2020 · 5 comments
Open

Cannot read property 'map' of undefined in production #34

codypearce opened this issue May 12, 2020 · 5 comments

Comments

@codypearce
Copy link

I installed the packages in the README and added gatsby-plugin-react-native-web to gatsbyjs-config. Everything works fine in development, but building the site and serving it in production causes the error below:

Codinhood | Codinhood 2020-05-12 07-11-24

"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-native": "^0.62.2",
"react-native-web": "^0.11.7",
"expo": "^37.0.10",
"gatsby": "^2.18.12",
"gatsby-plugin-react-native-web": "^3.1.0",

If I remove the plugin from the config then the issue goes away. I've used V2.0.0 on other Gatsbyjs sites, like https://material-bread.org, without running into this issue. Any ideas what might be wrong?

@slorber
Copy link
Owner

slorber commented May 12, 2020

Hi,

That's unfortunate, I'll have to check that.

Is material bread the repo you are trying to upgrade to v3.1?
Do you have a PR / branch to check?

The config has changed a lot with v3 as we are using the expo webpack config, which does much more than previous version.

@codypearce
Copy link
Author

codypearce commented May 13, 2020

I did some debugging and found disabling gatsby-plugin-offline allows it to work again. I tried to reproduce this behavior in an example repo but couldn't. Sorry, wish I could provide more info but the project is closed source at the moment.

I also found this issue: gatsbyjs/gatsby#10050, which describes the same problem with babel-preset-expo and babel-plugin-react-native-web.

@slorber
Copy link
Owner

slorber commented May 13, 2020

Thanks

Maybe it's related to service workers or something? Can you try with gatsby-plugin-offline but in a private browsing session?

Also, can you try to add this plugin first in the gatsby plugins list? (order may matter, but I don't think it's related here)

@codypearce
Copy link
Author

codypearce commented May 13, 2020

@slorber I was able to reproduce the problem in a stripped down example repo. https://github.com/codypearce/rnw-gatsbyjs-problem

You should be able to see the problem when building the static site and serving it:

npm i
npm run build
npm run serve

@slorber
Copy link
Owner

slorber commented May 14, 2020

thanks, I'll take a look at it probably this weekend or next week

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

2 participants