Skip to content

Commit 29a5599

Browse files
authored
fix: faq (#1864)
1 parent 71d0a4c commit 29a5599

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

react/modules/tasks/forms.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,110 @@
100100
- **5. Project Management**
101101
- Commits after the deadline: **-40 points**
102102
- Pull Request doesn't follow guideline (including checkboxes in Score) [PR example](https://rs.school/docs/en/pull-request-review-process#pull-request-description-must-contain-the-following): **-10 points**
103+
104+
## FAQ (Frequently Asked Questions)
105+
106+
### Should the modal close and the form reset after a successful submit?
107+
108+
Yes. Close the modal and clear the form.
109+
110+
### Do we store only the latest submission or all submissions?
111+
112+
Store all successful submissions (a history), and display them on the main page.
113+
114+
### Is Tailwind or icon libraries (e.g., lucide-react) allowed?
115+
116+
Yes. They are not UI component libraries.
117+
118+
### Can I keep the countries list in Zustand instead of Redux?
119+
120+
Yes.
121+
122+
### What branch and PR target?
123+
124+
Work in `forms`, open a PR to `main`.
125+
126+
### What exactly is an uncontrolled form here?
127+
128+
Inputs are not driven by React state (value). Read values via FormData, form onSubmit/onChange, or refs.
129+
130+
### In the uncontrolled form, do I need to disable the submit button?
131+
132+
No. Validate on submit only.
133+
134+
### May I attach onChange handlers in the uncontrolled form?
135+
136+
Yes, as long as you don’t set the input value programmatically.
137+
138+
### Should the uncontrolled form be implemented without React Hook Form?
139+
140+
Yes. Uncontrolled = without RHF; the other form = with RHF.
141+
142+
### In the RHF form, should the submit button be disabled when there are errors?
143+
144+
Yes, live (real-time) validation should disable submit.
145+
146+
### Is the image upload required?
147+
148+
Treat it as required and validate type/size, then store as base64.
149+
150+
### How do I convert the uploaded image to base64?
151+
152+
Use FileReader.readAsDataURL and save the result to the store.
153+
154+
### Is <input list> with <datalist> acceptable for country autocomplete?
155+
156+
Yes, but the countries list must live in the store and the value should be validated against it.
157+
158+
### Must the autocomplete accept only values from the list?
159+
160+
Yes, validate that the chosen value exists in the stored list.
161+
162+
### After reopening a modal, should fields be prefilled with previous data?
163+
164+
No. After a successful submit, reopen as empty.
165+
166+
### What accessibility is required for modals?
167+
168+
Focus trap, return focus to trigger, close on ESC, and close on outside click.
169+
170+
### Do I still need useEffect for loading/error states?
171+
172+
No. Use the form library/state and schema errors; no manual value control.
173+
174+
### How do I test file uploads?
175+
176+
Use userEvent.upload with a File instance in RTL tests.
177+
178+
### Must every required field render in both forms?
179+
180+
Yes. Both forms collect the same data and validate according to the schema.
181+
182+
### Do both forms have to use the same validation schema (Yup or Zod)?
183+
184+
Yes. Apply the chosen schema to both forms.
185+
186+
### How strict should email validation be in this task?
187+
188+
Keep it deliberately minimal. At this learning stage, validate only basic structure:
189+
190+
- exactly one @
191+
- non-empty local part before @
192+
- domain with at least one dot (e.g., example.com)
193+
- Avoid regular expressions. Do not validate with regex. Implement clear, step-by-step checks that you and reviewers can read (split by @, verify non-empty parts, ensure the domain has a dot, etc.).
194+
195+
### How to validate password vs confirmPassword with Zod in real time?
196+
197+
Use refine/superRefine with watch to compare fields.
198+
199+
### Does password strength block submission?
200+
201+
Not required. Only mismatched passwords (and other schema errors) must block.
202+
203+
### How to show password strength in the uncontrolled form?
204+
205+
Show an indicator via form/input onChange, or show a summary after submit errors.
206+
207+
### Can I implement password strength as text instead of a progress bar?
208+
209+
Yes. Any clear indicator is acceptable.

0 commit comments

Comments
 (0)