Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

accept function as argument in initialize() #199

Merged
merged 3 commits into from Mar 4, 2019
Merged

accept function as argument in initialize() #199

merged 3 commits into from Mar 4, 2019

Conversation

alirezavalizade
Copy link
Contributor

Usage:

initialize((values) => ({ ...values, any: null }))

@codecov
Copy link

codecov bot commented Feb 7, 2019

Codecov Report

Merging #199 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #199   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          12     12           
  Lines         514    515    +1     
  Branches      105    106    +1     
=====================================
+ Hits          514    515    +1
Impacted Files Coverage Δ
src/FinalForm.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b2aa455...31e4bf3. Read the comment docs.

@alirezavalizade
Copy link
Contributor Author

If you merge this, I'll send a pull request for react-final-form docs.
@erikras

@erikras
Copy link
Member

erikras commented Feb 7, 2019

Can you describe the use case for this?

@alirezavalizade
Copy link
Contributor Author

Sure, Sometimes i need to change value of a field but also need to keep the current values of form,
for example:

initialize({
  posts: 'a value'
})

If i use this other fields will lose their values. But i need to keep my current values and just change one field. and also i don't want to set values in state on changing the form. I know it's possible using change method in finalForm state but sometimes need to this. It's nice to have it.
Take a look at this sandbox please

@erikras
Copy link
Member

erikras commented Feb 8, 2019

Well, this could be accomplished like this:

Edit 🏁 React Final Form - Loading and Initializing

You have all the information you need to initialize with all the values.

@alirezavalizade
Copy link
Contributor Author

@erikras Thanks for your reply, Yes i agree it, but really sometimes need to access current values for initialize the form. I can create another Sandbox,

@lock
Copy link

lock bot commented Apr 3, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants