Harshad Naik
Harshad Naik

Reputation: 86

In CRA 4.0.0 we dont require to import react from react anymore

I am a beginner learning react and I recently used the CRA 4.0.0 boilerplate where I noticed that we don't need to import react anymore, I have this question that, how was the CRA developer team able to implement this change ?

Upvotes: 0

Views: 256

Answers (1)

ddprrt
ddprrt

Reputation: 7574

The React team switched to a new, more generic JSX transform (transpiling your JSX-Components into function calls) with a stricter naming convention. This allows transpilers/compilers like Babel or TypeScript to inject the transform on compile, rather than you having to specify it for each component. See https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html

In theory, this should help to make components easier transportable between frameworks. However, the moment you need a hook or similar, you need to import that hook from the React package again.

Upvotes: 2

Related Questions