Reputation: 1681
I'm building a simple app with react native using among other things Expo. After an update of react, expo, react-native from a previous version, I get an error I cannot seem to get rid of (see picture). I have looked in index.js, MainNavigator.js, LoginNavigator.js to ensure that I have import React, {Component } from 'react';
in the preamble, but the problem persists. Can anyone guide me in a direction to help solve this problem?
Also tried:
exp install:ios
to make sure that I have the latest version on the simulatorwatchman watch-del-all && react-native start --reset-cache
and watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache verify && npm install && npm start --reset-cache
npm install exp --global
app.json
package.json
, deleting node_modules
and then running exp start -c
.react-native link
.import React from 'react';
and then ... extends React.Component
react-native
, expo
and react
again using ´npm install [package] --save`Upvotes: 3
Views: 22348
Reputation: 83
see that if you are use classes in react-native then you should add {component} from react as given below.
import {component} from React;
Upvotes: -2
Reputation: 516
I've experienced this before, after searching all thorough the codebase, finally, I found it where I couldn't believe it'll be App.js
file. So if you've tried restarting your bundler and running npm start --reset-cache
or yarn start --reset-cache
, and the issue still persist, check all your files and components you worked on, you imported React
without importing Component
, for instance:
import React, {Component} from 'react';
Upvotes: 0
Reputation: 537
I have fixed this issue in my project. First add react-native to your packages.
yarn add react-native
Then changing below line:
OLD
import React from 'react';
NEW
import React, {Component} from 'react';
Upvotes: 3
Reputation: 523
My solution was changing this line as:
From
import React from 'react';
To
import React, {Component} from 'react';
Upvotes: 14
Reputation: 8936
When upgrading expo versions, make sure you follow their upgrading guide and do it one version at a time: https://blog.expo.io/expo-sdk-v25-0-0-is-now-available-714d10a8c3f7
Upvotes: 3