Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

handleChange can't target state values with delimiters #3925

Open
YoussefEgla opened this issue Dec 5, 2023 · 0 comments
Open

handleChange can't target state values with delimiters #3925

YoussefEgla opened this issue Dec 5, 2023 · 0 comments

Comments

@YoussefEgla
Copy link

YoussefEgla commented Dec 5, 2023

Bug report

handleChange can't target state keys with delimiters ex: traits.email
Does not work on browser and react native

Current Behavior

having an initial value {["traits.email"]: "", ["traits.password"]: ""} doesn't update on value change when using props.handleChange("traits.email")

However when I directly update the react state it does work as expected

Expected behavior

The value should update when using onChangeText={props.handleChange("traits.email")} in react native and onChange{props.handleChange} in browser (made sure name is set)

Reproducible example

The following example clearly shows what happens
Reproducible example

Suggested solution(s)

Currently, I am updating the internal react state directly which works as expected. I couldn't target the location where the state gets updated in Formik lib (skimmed through it TBH)

const handleChange = (k: string) => (t: string) => {
  formik.setValues({ ...formik.values, [k]: t });
};

Additional context

These IDs approach are used by kratos

Your environment

Software Version(s)
Formik 2.4.5
React 18.2.0
React Native 0.72.6
Expo 49.0.15
TypeScript 5.1.3
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant