Skip to content

Commit

Permalink
fix onclick handler
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsbajorics committed Oct 3, 2024
1 parent a4a1144 commit 22a3a62
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions app/routes/_index/sections/hero.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import * as React from 'react'
// import { Button } from '@h2/new/Button'
// import { Heading, Text } from '@h2/new/Text'

export default function Hero() {
return (
Expand Down Expand Up @@ -38,11 +36,10 @@ export default function Hero() {
}

function Counter() {
const [clickCount, setClickCount] = React.useState(0)
const renderCount = React.useRef(0)
renderCount.current += 1

const onClick = React.useCallback(())

return (
<div style={{ contain: 'layout' }}>
<div>Render count:{renderCount.current}</div>
Expand All @@ -53,8 +50,12 @@ function Counter() {
backgroundColor: 'red',
}}
/>
<div
<button
onClick={() => {
setClickCount((prev) => prev + 1)
}}
style={{
cursor: 'pointer',
backgroundColor: '#aaaaaa33',
position: 'absolute',
left: 26,
Expand All @@ -63,9 +64,8 @@ function Counter() {
height: 45,
}}
>
click me
<br />
</div>
click me {clickCount}
</button>
</div>
)
}

0 comments on commit 22a3a62

Please sign in to comment.