Why the onChange
props is different between components ?
#1187
Answered
by
rtivital
MatteoGauthier
asked this question in
Q&A
-
Hey I wanted to know how to manage different onChange props from mantine components. // onChange argument is a string
<ColorInput
onChange={(color) => handleChange("button-color", color)}
id="button-color"
placeholder="Pick color"
swatches={availableColors}
withPicker={false}
swatchesPerRow={6}
disallowInput
/>
// onChange is a native Event
<Switch
id="button-shadow"
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
handleChange("button-shadow", event.target.checked)
}
onLabel="ON"
offLabel="OFF"
label={"I agree to sell my privacy"}
radius={"lg"}
size="md"
classNames={{
label: "text-sm pl-2 mb-0.5",
}}
/>
|
Beta Was this translation helpful? Give feedback.
Answered by
rtivital
Apr 5, 2022
Replies: 1 comment 3 replies
-
Because some components do not have access to event, when event is available, it is always provided to onChange handler. You can use use-input-state hook to handle that. |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
rtivital
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Because some components do not have access to event, when event is available, it is always provided to onChange handler. You can use use-input-state hook to handle that.