Skip to content

Instantly share code, notes, and snippets.

@paulodutra
Created August 23, 2023 13:33
Show Gist options
  • Save paulodutra/117a43b39faa0158a09fd3cac1852ca1 to your computer and use it in GitHub Desktop.
Save paulodutra/117a43b39faa0158a09fd3cac1852ca1 to your computer and use it in GitHub Desktop.
Example using useState with parameter to other component - 2/2
import React from 'react'
type ButtonProps = {
increment: React.Dispatch<React.SetStateAction<number>>
}
export const Button = ({increment }: ButtonProps) => {
return <button onClick={() => increment((number) => number + 1)}>Increment</button>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment