Are these two methods exactly the same?
liuseen-l opened this issue · comments
LiuSeen commented
const { age } = useStore()
const age = useStore((state) => state.age)
The first way feels more convenient, but the official website cases are written in the second way. do two different ways of getting a value have different implications?
Danilo Britto commented
@liuseen-l the first way would cause extra renders if you want to only re render a component when age changes that's why you need to use a selector, the second use a selector in order to optimize that