Commit d15c102f authored by Robert Knight's avatar Robert Knight

Respond to code review feedback

 - Simplify an example. `useCallback` is not required.
 - Add a comment regarding effect cleanup
parent 62b99843
......@@ -20,9 +20,7 @@ const warnOnce = require('../util/warn-once');
*
* @example
* function MyWidget({ widgetId }) {
* const widget = useStore(
* useCallback(store => store.getWidget(widgetId), [widgetId])
* );
* const widget = useStore(store => store.getWidget(widgetId));
* const hideWidget = useStore(store => store.hideWidget);
*
* return (
......@@ -81,6 +79,8 @@ function useStore(callback) {
// Check for updates when the store changes in future.
const unsubscribe = store.subscribe(checkForUpdate);
// Remove the subscription when the component is unmounted.
return unsubscribe;
}, [forceUpdate, store]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment