Skip to content

Commit

Permalink
feat: Use useCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
atomita committed Oct 26, 2019
1 parent 9efb497 commit 18f289e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/app.tsx
@@ -1,14 +1,15 @@
import React, { useState } from 'react';
import React, { useState, useCallback } from 'react';
import * as ReactDOM from 'react-dom';


function Application () {
const [cnt, setCnt] = useState(0)
const handleClick = useCallback(event => setCnt(cnt + 1))

return (
<div>
<div>
<button onClick={event => setCnt(cnt + 1)}>click</button>
<button onClick={handleClick}>click</button>
</div>
count: {cnt}
</div>
Expand Down

0 comments on commit 18f289e

Please sign in to comment.