import { Layout } from '@/layout'; import { MDX_DATA } from '@/mdx'; export default Layout(MDX_DATA.useInputState); ## Usage The `use-input-state` hook handles the state of native inputs (with event in `onChange` handler) and custom inputs (with value in `onChange` handler). The hook works with all Mantine and native inputs: ```tsx import { useState } from 'react'; import { NumberInput, TextInput } from '@mantine/core'; import { useInputState } from '@mantine/hooks'; function WithUseInputState() { const [stringValue, setStringValue] = useInputState(''); const [numberValue, setNumberValue] = useInputState< string | number >(0); return ( <> ); } function WithUseState() { const [stringValue, setStringValue] = useState(''); const [numberValue, setNumberValue] = useState(0); return ( <> setStringValue(event.currentTarget.value) } /> setStringValue(event.currentTarget.value) } /> ); } ``` ## Definition ```tsx type UseInputStateReturnValue = [ T, (value: null | undefined | T | React.ChangeEvent | ((current: T) => T)) => void, ]; function useInputState(initialState: T): UseInputStateReturnValue ``` ## Exported types `UseInputStateReturnValue` type is exported from `@mantine/hooks` package, you can import it in your application: ```tsx import type { UseInputStateReturnValue } from '@mantine/hooks'; ```