Module '"./node_modules/react-native"' has no exported member 'View'

Viewed 4838

After i convert my project in typescript showing me following error Module '"./node_modules/react-native"' has no exported member 'View'.

import React from 'react';
import {StyleSheet,View,Text} from 'react-native';

export default function App() {
return (
  <View style={{ flex: 1 }}>
    <Text>Welcome</Text>
  </View>
 );
}
3 Answers
  1. Delete your node_modules folder
  2. run this on your terminal npm install @types/react @types/react-native
  3. close the editor and restart everything.

Delete node_modules folder and run npm install or yarn again.

If it not solve this problem, try to run npm install @types/react @types/react-native or yarn add @types/react @types/react-native

Probably you should also use -D option to install it as a development dependency, which adds it to the devDependencies list.

npm install --save-dev @types/react @types/react-native
(npm install -D @types/react @types/react-native)

or

yarn add --dev @types/react @types/react-native
(yarn add -D @types/react @types/react-native)
Related