Search code examples
reactjsreact-redux

can we use useSelector directly


Normally it's been seen as using useSelector as follows

const count = useSelector(getCount);
addCount(count)

Is there any issue if we are using useSelector like given below?

addCount(useSelector(getCount))

Solution

  • It still works! But best practice and clean code, you should write like first option!

    const count = useSelector(getCount);
    addCount(count)