casesandberg / casesandberg/react-color

Recommendation for using React-Color with Formik

Open
#856 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
12.3k
Forks
920
PR merge metrics
No merged PRs in 30d

Description

Hi,

We want to use React-Color as part of a Formik form.

Formik is not picking up the change values & using onChangeComplete is causing a crash. Does seem related to the onChange interactions between Formik and React-Color.

Any guidance or sample code woudl be appreciated since we'd really like to use React-Color versus trying to write our own. (We liked the palette picker)

Our implementation is below:

```
const FormikColorPicker = memo(({
label, description, key, id, name, hidden, colors, width, ...props
}) => {
const { handleBlur, handleChange, setFieldValue } = useFormikContext();
const [field] = useField(name);
const onCompleteFunc = (color, e) => {
setFieldValue(field.name, color.hex);
};

return (



{label}


{description && {description}}

```
Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.