D
D
DyadkoOrest2021-03-29 15:30:31
React
DyadkoOrest, 2021-03-29 15:30:31

Is it possible to do without the constant import of hooks from react?

To use hooks I import each one from react.

import React, { useEffect, useState } from 'react';

But it seems to me that in recent updates it has become optional. Whether prompt it is possible to use hooks without preliminary import.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tigran Abrahamyan, 2021-03-29
@TAbrahamyan

Note how our original code did not need to import React to use JSX anymore! (But we would still need to import React in order to use Hooks or other exports that React provides.)

https://reactjs.org/blog/2020/09/22/introducing-th...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question