If you try to do an import in Typescript, you can get an error like this:
index.tsx(10,25): error TS2304: Cannot find name 'React'.
In order to do an import successfully, you probably did something like below, or set up tsconfig.json (either should work):
///
When you write the Javascript code, it should look similar to the following:
Garys-MBP:youtube gary$ cat app/index.tsx
import * as React from 'react';
interface IMessage {
msg: String;
}
class TestApp extends React.Component {
public render(): Element {
return test;
}
}
If you’re receiving the above error, the most likely cause is that you have a case-sensitivity issue: either you’re alternating case in Javascript class names, or you installed “React” with npm but reference it as “react” in your import (make sure you are consistent within your project, or this will fail hard)