A
A
Anim8262021-02-01 15:11:21
JavaScript
Anim826, 2021-02-01 15:11:21

React no longer needs to include it?

I’m watching a 2020 course on React and there, when a person was making one of the components, he got an error and had to write:
import React from 'react';
But at the same time, when I didn’t write it, everything worked.
As I understand it, there was an update and the need to add was removed? Or is it still better to prescribe in the code just in case:
import React from 'react';

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Tigran Abrahamyan, 2021-02-01
@Anim826

if some hooks are not used, for example useState, or useEffectthen you can not connect

A
AveWycc, 2021-02-01
@AveWycc

Most likely you have React loaded on an HTML page (as in the picture below), in which case you do not need to import it as a module.
6017f0c6ecbf7161788867.png
Another way to connect is to install the react library via npm and import it in code. Everything is written about this in the React docks, I advise you to watch them, and not videos, especially since there is a Russian language there.
import React from 'react';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question