Skip to content

Commit 3813c3e

Browse files
author
Marcel Fischer
committed
review fixes
1 parent b97a638 commit 3813c3e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

06-form.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ We are also going to consider error messages for these form elements.
88
In my earlier React times, I thought it was a good idea to store fetched endpoint data directly
99
as component state to finally pass it down to child components.
1010
This came with major drawbacks like bringing the state in the right format in every child component on every render cycle.
11-
Sometimes the same had to be done multiple times. Not that good for performance and
12-
[DRY](https://de.wikipedia.org/wiki/Don%E2%80%99t_repeat_yourself).
11+
Sometimes the same computation had to be done even multiple times. Not that good for performance and the
12+
[DRY](https://de.wikipedia.org/wiki/Don%E2%80%99t_repeat_yourself) principle.
1313

1414
It got even worse when error messages had to be displayed for some form elements.
1515
These error messages were saved in another state variable and had to be mapped to the right
@@ -20,8 +20,8 @@ computation of data can be kept to a minimum while rendering the component tree.
2020

2121
This goes also hand in hand with the
2222
[low coupling principle](https://stackoverflow.com/questions/14000762/what-does-low-in-coupling-and-high-in-cohesion-mean):
23-
Once the API changes, we only need to change the transformer function which takes in delivered data from the API
24-
and outputs the corresponding UI state.
23+
If the API changes for any reason, we only need to change the transformer function which takes in the
24+
delivered data from the API and outputs the corresponding UI state.
2525

2626
### 6.2 Defining the `TextFieldState`
2727
According to our learnings in the past it would be nice to have a state for every form element.
@@ -308,8 +308,8 @@ I suggest using a `data` and `onChangeData` property:
308308
```typescript jsx
309309
// src/packages/core/form/TextField.tsx
310310

311-
import { TextFieldState } from './formElementState';
312311
import React, { CSSProperties, FC } from 'react';
312+
import { TextFieldState } from './formElementState';
313313
import { TextField as MuiTextField, InputProps, FormControl } from '@mui/material';
314314
import { Messages } from './Messages';
315315

@@ -384,7 +384,7 @@ Let's do the same for the checkbox form element:
384384
// src/packages/core/form/Checkbox.tsx
385385

386386
import React, { FC, ReactNode } from 'react';
387-
import { CheckboxState } from '@packages/core/form';
387+
import { CheckboxState } from './formElementState';
388388
import { Checkbox as MuiCheckbox, FormControl, FormControlLabel } from '@mui/material';
389389
import { Messages } from './Messages';
390390

0 commit comments

Comments
 (0)