Skip to content

Commit

Permalink
fix: πŸ› new React behaviour needs useState to set something
Browse files Browse the repository at this point in the history
Issues: closes #128
  • Loading branch information
streamich committed Feb 25, 2019
1 parent d789288 commit e926faf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/__stories__/useGetSet.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ const DemoWrong = () => {

storiesOf('State/useGetSet', module)
.add('Docs', () => <ShowDocs md={require('../../docs/useGetSet.md')} />)
.add('Demo', () =>
.add('Demo, 1s delay', () =>
<Demo/>
)
.add('DemoWrong', () =>
.add('DemoWrong, 1s delay', () =>
<DemoWrong/>
)
5 changes: 4 additions & 1 deletion src/useUpdate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import {useState} from 'react';

const useUpdate = () => useState(0)[1] as (() => void);
const useUpdate = () => {
const [, setState] = useState(0);
return () => setState(cnt => cnt + 1);
};

export default useUpdate;

0 comments on commit e926faf

Please sign in to comment.