slorber / gatsby-plugin-react-native-web

react-native-web plugin for Gatsby

Home Page:https://sebastienlorber.com/using-expo-in-gatsby

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot read property 'map' of undefined in production

codypearce opened this issue · comments

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?

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.

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.

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)

@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

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