React Native and Expo make it surprisingly easy to code a cross-platform app, but beginners can still get hung up on unfamiliar or confusing error messages. To help solve your error, type it into the search box or jump to a list of debugging techniques.
Brought to you by the Just-in-Time Learning platform of the University of Maine's New Media major. Submit a comment or suggestion via ude.eniam@otiloppij or @jonippolito.
This is usually a delimiter (punctuation mark) out of place.
That usually means you didn't import a needed component, custom or default.
This can happen when a component is stuck refreshing the screen endlessly.
This usually means you forgot to define or export a component. Or you might not have used the exact same name--with identical capitalization and spelling--for the component in its various occurrences. (Watch out for plurals inside camelCase words, eg petScreen versus petsScreen.) Check your naming consistency in:
A "minified" error is too long to fit in the phone screen, but includes a URL you can load in a separate browser window. The component that threw the error is often listed at the end (eg, Input[]).
The URL for this minified error (https://reactjs.org/docs/error-decoder.html?invariant=31....) leads to an error page that says Objects are not valid as a React child. This can sometimes mean you tried passing the wrong kind of attribute to a child component. For example, you can't pass an object or an attribute directly inside JSX tags.
The URL for this minified error (https://reactjs.org/docs/error-decoder.html?invariant=130....) leads to an error page that says Element type is invalid: expected a string ... or a class/function ... but got: object.. This is usually the same problem as Module not defined.
The URL for this minified error (https://reactjs.org/docs/error-decoder.html/?invariant=152...) leads an error page that says Nothing was returned from render.
const Card = () => {
return (
<View>
<Text>
...
)
}
const EmptyCard = () => {
return null
}
The URL for this minified error (https://reactjs.org/docs/error-decoder.html/?invariant=301...) leads to an error page that says Too many re-renders. This error means React is stopping you from creating an infinite loop by re-rendering a condition over and over.
const [ isLoggedIn, setIsLoggedIn ] = useState(false) ; // This sets an initial state.
// This is always true and will re-render the screen endlessly.
setIsLoggedIn( true ); â
// This only re-renders once the user has logged in.
if ( password === "girlboss" ) { setIsLoggedIn( true ) } ; â
Although this error doesn't always come with a line number, the problem is likely inside a return(...) statement.
// Bad.
return(
...
;)
// Good.
return(
...
);
<View>{ "I'm not supposed to be here!" }</View>
age > 18 && <AdultContent /> â
age > 18 ? <AdultContent /> : null â
You could be triggering too many refreshes with useEffect
This message means you've returned two "sibling" tags instead of a parent to contain them. This error will be at the highest level of one of your return statements.
// This will fail â
{ !isLoggedIn?
(
<LoginForm />
) : (
<Text> Welcome to My Pet Finder app</Text>
<SubmitButton whenPressed={() => navigation.navigate('Pets')}>
See Your pets
</SubmitButton>
)
}
// This will succeed â
{ !isLoggedIn?
(
<LoginForm />
) : (
<View>
<Text> Welcome to My Pet Finder app</Text>
<SubmitButton whenPressed={() => navigation.navigate('Pets')}>
See Your pets
</SubmitButton>
</View>
)
}
(eg, for a Card):
<Card petType = "Bulldog" />
...
const Card = props => {
return (
<Text>{ props.petBreed }</Text> âšī¸
)
}
This can be a problem with the configuration code you are supposed to import at the top of your file.
{
"dependencies": {
"firebase": "*",
...
}
}
{
"dependencies": {
"firebase": "8.0.0",
...
}
}
if ( !firebase.apps.length ) firebase.initializeApp( firebaseConfiguration ) ;
Check the button that navigates to your detail screen. If you're navigating to a component (like a detail screen) that depends on custom parameters, you'll need to pass an object containing them as a second argument to navigation.navigate.
<Button onPress={ () => navigation.navigate(
"Pets",
{
petName,
petBreed,
petAge
}
) }>
This is necessary even if you are using the streamlined useNavigation() hook, but only when the next screen depends on data from the first.