React Native: 'React' refers to a umd global but the current file is a module consider adding an import instead

Viewed 20738

I was getting this error while adding a View component in .tsx file.

4 Answers

One don't need to import everything using *

It's just react which is missing and needs to be imported so that JSX can be understood.

So just do following

import React from 'react';

Try importing in this way

import React, {Component} from 'react';

Use any of the following to remove the error:

declare var React: any;
var React;
import React from "react";
import * as React from "react";
Related