Conditionally declare a state in React

后端 未结 0 1577
栀梦
栀梦 2021-01-28 10:43

Can I set up a state only if a certain prop provided? Something like this:

function Comp({scroll, children}) {
    const [scrollY, setScrollY] = useState(0);
             


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题