DEV Community

Damian Diego
Damian Diego

Posted on

React doubt: React.useEffect or useEffect

Hi devs!

The last days I was looking into some react repos because I want to implement a component library on my own. And I realized that many people now are using React functionalities via React object.

import * as React from 'react'

/*functional component declaration*/
const [count, setCount] = React.useState(0)

React.useEffect(() => {
 //some logic here
},  [])
Enter fullscreen mode Exit fullscreen mode

What is the porpoise of this? What about just importing directly what you need?

Top comments (1)

Collapse
 
artxe2 profile image
Yeom suyun

The official documentation import that with way you want

react.dev/reference/react/useState