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

Neon image

Next.js applications: Set up a Neon project in seconds

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Get started →

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay