NISHIO Hirokazu[Translate]
storeのsubscribeとuseEffect
storeのsubscribeとuseEffect
storeのsubscribeとuseEffectが意味合い的に重複しているけどどっちをどう使うのが良いのか
こんな感じで良いのかlistenerにした方がいいのか
ts
useEffect(() => { ... }, [store.getState().items]);

subscribeの説明を読む
>It is a low-level API. Most likely, instead of using it directly, you'll use React (or other) bindings. If you commonly use the callback as a hook to react to state changes, you might want to write a custom observeStore utility. The Store is also an Observable, so you can subscribe to changes with libraries like RxJS.

"Engineer's way of creating knowledge" the English version of my book is now available on [Engineer's way of creating knowledge]

(C)NISHIO Hirokazu / Converted from [Scrapbox] at [Edit]