Last active
April 19, 2022 12:01
-
-
Save itkrt2y/54f860571ea8109c13bba77b2d37c2fc to your computer and use it in GitHub Desktop.
react-hook-form + ChakraUI NumberInput
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
NumberDecrementStepper, | |
NumberIncrementStepper, | |
NumberInput, | |
NumberInputField, | |
NumberInputStepper, | |
} from "@chakra-ui/react"; | |
import { Controller } from "react-hook-form"; | |
<Controller | |
name="sample" | |
control={control} | |
render={({ field: { ref, onChange, ...rest } }) => ( | |
<NumberInput {...rest} onChange={(_, v) => onChange(v)}> | |
<NumberInputField ref={ref} /> | |
<NumberInputStepper> | |
<NumberIncrementStepper /> | |
<NumberDecrementStepper /> | |
</NumberInputStepper> | |
</NumberInput> | |
)} | |
/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment