Comments (10)
That's an anti-pattern. The general rule of thumb for Redux, and React in general, is:
If you can calculate it from the state, don't store it in the state.
The less state the better.
If you want to do it anyway, you'll need your own Redux reducer, much like how this form keeps saveError
separate, to keep it. This library isn't going to support keeping validation state in the store.
from redux-form.
Thanks. But what if I need to show the form validation state (valid/invalid) in an another component?
from redux-form.
Two options:
connect()
to the form data andimport
and run your validator in the other component.- Just
connectReduxForm()
in the other component and read the props. It doesn't matter how many components connect to the same form.
from redux-form.
#49 will help with this when it gets implemented.
from redux-form.
Just connectReduxForm() in the other component and read the props. It doesn't matter how many components connect to the same form.
Thanks. So if I have async validation and i will connect two components to the same form, then the asynchronous validation will be performed twice?
from redux-form.
Good question. No, the async validation will only be fired when the BLUR
action is sent, so as long as you are only sending it from one of the components (which is necessarily the case), the async validation will only happen once, but will be displayed (available to) both components. Make sense?
from redux-form.
Thanks!
from redux-form.
Sorry, I still not understand.
Following the discussion, if I have two components which want to know about the validation state, then I should connect them both to the form and should pass the same validation function to connectReduxForm
. Is it correct?
If it is, then it means, that the validation function will be called twice, during rendering of the first and the second components. How to avoid this?
from redux-form.
@anatoliyarkhipov Your validation function should be quite fast, but if it isn't, then memoize it.
from redux-form.
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.
from redux-form.
Related Issues (20)
- meat.error
- Redux Form 8.3.6 - Huge form Sluggish HOT 1
- Form submission canceled because the form is not connected.
- syncError is not recognizing unrecognized Fields
- Malicious code on api documentation site HOT 5
- Inline validate causing infinite loop (Maximum update depth exceeded)
- redux-form/examples HOT 4
- Using connect from react-redux with reduxForm HOC throws an error
- Radio field never gets touched with MUI - cannot validate
- how to select form value and put condition accordingly field array in redux form
- error UNSAFE_componentWillReceiveProps and UNSAFE_componentWillMount
- [Bug] : Redirect to Github link is broken
- Support React 18 HOT 9
- Multiple button needs reference in fieldArray onClick={() => fields.push({})}
- Scrollbar jumps on wizard example
- Support react-redux 8.x.x HOT 4
- validate does not trigger with new initialValues HOT 9
- Component mounts twice after going to different page from redux form
- Text characters are getting deleted in TextArea on iOS
- Security Vulnerability with Lodash version 4.17.15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redux-form.