diff --git a/README.md b/README.md index f76e555..41ba06d 100644 --- a/README.md +++ b/README.md @@ -263,7 +263,7 @@ Only runs the callback when inputs change and not during mounting. ```ts interface Props { fn: () => void | VoidFn; - inputs?: any[]; + inputs: any[]; // unlike UseEffect, this is required. comparator?: EqualityFn; } ``` diff --git a/src/UseEffectOnUpdate.tsx b/src/UseEffectOnUpdate.tsx index 1786344..ce5366f 100644 --- a/src/UseEffectOnUpdate.tsx +++ b/src/UseEffectOnUpdate.tsx @@ -4,7 +4,7 @@ import { EqualityFn, VoidFn } from './utils'; interface Props { fn: () => void | VoidFn; - inputs?: any[]; // eslint-disable-line @typescript-eslint/no-explicit-any + inputs: any[]; // eslint-disable-line @typescript-eslint/no-explicit-any comparator?: EqualityFn; } diff --git a/stories/UseCallback.story.tsx b/stories/UseCallback.story.tsx index 1b0d2af..82d172b 100644 --- a/stories/UseCallback.story.tsx +++ b/stories/UseCallback.story.tsx @@ -28,7 +28,7 @@ function ConditionalExample(props) { return (
Update: {count}
-Function called: {called}
+Function Called: {called}
@@ -48,7 +48,7 @@ function OnceOnceExample(props) { return (Update: {count}
-Function called: {called}
+Function Called: {called}
diff --git a/stories/UseEffect.story.tsx b/stories/UseEffect.story.tsx index a6e4e39..ed117ba 100644 --- a/stories/UseEffect.story.tsx +++ b/stories/UseEffect.story.tsx @@ -4,10 +4,36 @@ import { storiesOf } from '@storybook/react'; import { action } from '@storybook/addon-actions'; import withState from './withState'; import UseEffect from '../src/UseEffect'; +import withDemoHelper from './withDemoHelper'; const { Fragment } = React; function Example(props) { + const { count, setCount, called, setCalled } = props; + + return ( +Update: {count}
+Function Called: {called}
+ + +
+ {`(Use "
Update: {count}
+Function Called: {called}
+ + +
+ {`(Use "
- Note: You'll need to use your browser devtools sensors + Note: You might need to use your browser devtools sensors to simulate location changes.