Skip to content

Commit 0dbaac5

Browse files
author
Kuldeep Saxena
authored
Update README.md
1 parent ec799f3 commit 0dbaac5

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,59 @@ export default class Login extends Component {
249249
* [Getting Started](docs)
250250
* [API](docs/api/)
251251

252+
# FAQ
253+
254+
### How is it different from other form libraries?
255+
256+
React has many libraries which works on the form logic, but here are some concerns with these:
257+
258+
#### Code Complexity
259+
If you’re using the redux-form then you should know the pain, for just a two field login form you’d to write the store logic.In RRF you can see that how simple is to deal with simple and complex forms.
260+
261+
`And one of the awesome thing is that you can just write your form controls logic anywhere in your application.`
262+
263+
#### Dependencies
264+
Many libraries come with dependencies for e.g redux is required for redux-form, So what If I’m using another state management or not event using any.
265+
According to Dan Abramov, form state is inherently ephemeral and local, so tracking it in Redux (or any kind of Flux library) is unnecessary.
266+
RRF comes with `zero` dependency, So it’s totally up to you that how you want to save your form state if needed.
267+
268+
#### Performance
269+
Now that’s a big problem with almost all libraries when you're dealing with large forms.
270+
271+
How RRF does solve performance issues ?
272+
- It uses subscription to update the components so rather updating all the fields on every input changes, it only update the particular field for which the state change takes place.
273+
- RRF has a nice option to define that when(blur, submit or change) to update your form's state by using the `updateOn` property.
274+
275+
#### Dynamic Changes
276+
With the help of subscribers it's pretty easy to listen for a particular state changes and modify the controls accordingly.
277+
278+
279+
### What are `value` and `status` changes subscribers?
280+
281+
RRF uses inbuilt `Subject`, A `Subject` is an object with the method next(v).To feed a new value to the Subject,RRF just calls the next(theValue), and it will be multicasted to the Observers registered to listen to the Subject.
282+
So basically it provides three subjects for each AbstractControl `valueChanges`, `statusChanges` and `stateChanges` and additional two subjects for FormControl ( `onValueChanges`, `onBlurChanges`)
283+
You can register an observer to a particular Subject to do some actions whenever some particular changes happen.
284+
285+
Example:
286+
287+
```ts
288+
componentDidMount() {
289+
this.myForm.get(“gender”).valueChanges.subscribe((value) => {
290+
// do something
291+
})
292+
}
293+
```
294+
Checkout the [Basic usage guide](docs) for more details.
295+
296+
### How the Field components work?
297+
298+
Field components are subscribed to the state changes of a particular control which means that it’ll re-render the component only when it’s state changes disregarding of other field changes.You can also implement your custom wrappers by using the stateChanges `Subject`.
299+
300+
### How updateOn feature works?
301+
302+
Its an another performance booster in RRF, it just holds the computation needed to be made after every keystroke or value changes until you want to execute.It has three options `change`(default), `blur` and `submit`, you can define all of them at both field and record level.
303+
304+
252305
# Code Sandboxes
253306
Try out `react-reactive-forms` in these sandbox versions of the Examples.
254307
* [Simple Form](https://codesandbox.io/s/4rxokpr270)
@@ -258,6 +311,7 @@ export default class Login extends Component {
258311
* [Update On Submit](https://codesandbox.io/s/3qk1ly16j1)
259312
* [Multi-page Wizard Form](https://codesandbox.io/s/zk1m06r5y3)
260313

314+
261315
Let's make React Reactive Forms better! If you're interested in helping, all contributions are welcome and appreciated.
262316

263317
And don't forget to star the repo, I will ensure more frequent updates! Thanks!

0 commit comments

Comments
 (0)