Hello I am trying to generate unique react components but a problem I have is they share their ReactHooks, how can I have each component not share their hooks and be unique?
When you create a hook in a react component, they are not supposed to interact each other
function component1() {
const [name, setName] = useState("name1");
return <component2 />
}
function component2() {
const [name, setName] = useState("name2");
return <div>{name}</div>
}
The functions will be unique by default. You're probably doing something wrong somewhere in your code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.