Custom input with initial value is not working

Open
#134 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, react, react-native
Domain
frontend, mobile

Research direction

Start at the WithFormikControl implementation shown in the issue and inspect how its mapProps function selects the input value from Formik values and the value prop. Verify the precedence when an initial value is supplied, then update the selection so the reported getValue result is not overridden. Done means custom inputs preserve the intended initial value behavior.

Written by the indexing model from the issue text.

Description

If we give initial value as per the code in WithFormikControl the initila value from props always overrides the value got from getValue

const withFormikControl = compose( withErrorIfNeeded, connect, mapProps( ({ formik: { values, setFieldValue, setFieldTouched }, name, value, ...props }) => ({ value: get(values, name) === undefined ? value : get(values, name), setFieldValue: (value, ...args) => setFieldValue(name, value, ...args), setFieldTouched: (value, ...args) => setFieldTouched(name, value, ...args), name, ...props }) ) );

this should be the code

Dominant language
JavaScript
Stars
398
Forks
50
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bamlab/react-native-formik

All issues in bamlab/react-native-formik

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.