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

chore: add Troubleshooting section to React Native docs #10723

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/source/integrations/react-native.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,21 @@ For more information on setting up Apollo Client, see [Getting started](../get-s
1. Install React Native Debugger and open it.
2. Enable "Debug JS Remotely" in your app.
3. If you don't see the Developer Tools panel or the Apollo tab is missing from it, toggle the Developer Tools by right-clicking anywhere and selecting **Toggle Developer Tools**.

## Troubleshooting

Here are a few common React Native problems and solutions.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Borrowed this Troubleshooting format from the apollo-link-rest page. Checking to see if there are any other points to call out here from past RN-related issues, but if there's only one I'll remove this line.


* `Uncaught Error: Cannot read property 'prototype' of undefined`, or similar Metro build error -- This is due to the way [the Metro bundler supports `.cjs` and `.mjs` files](https://github.com/facebook/metro/issues/535#issuecomment-1198071838): it requires additional configuration to _implicitly_ resolve files with these extensions, so `import { ApolloClient, InMemoryCache } from '@apollo/client` will result in an error. You can amend your import statement to e.g. `import { ApolloClient, InMemoryCache } from '@apollo/client/main.cjs';`, or you can install `@expo/metro-config` and configure their implicit resolution via `metro.config.js` in the root of your project:
alessbell marked this conversation as resolved.
Show resolved Hide resolved
alessbell marked this conversation as resolved.
Show resolved Hide resolved

```js
const { getDefaultConfig } = require('@expo/metro-config');

const config = getDefaultConfig(__dirname);

config.resolver.sourceExts.push(
'cjs'
);

module.exports = config;
```