import { useState } from "react";
const [count, setCount] = useState(0)
const [count, setCount] = React.useState(0)
Which one is better to use and why?
I'm looking for which approach is better and why?
CodePudding user response:
They are identical. Why you'd use one over the other is basic styling preference
CodePudding user response:
They’re the same function, you’re just importing them differently. In the first example, you imported just useState from React by deconstructing it.
While in the second, you imported the whole react library, thus requiring you to write React.useState.