6th Practical Class:
Forms and More
- EditorConfig & Prettier
- React Inputs
- Formik
- Form Validations
EditorConfig
- https://editorconfig.org/
- see editorconfig Atom plugin
- open
.editorconfig
when using with Remote FTP plugin
- open
.editorconfig
example:
Prettier
Code Formatter:
- "Ugly Code" -> "Nice Code"
supports:
- JavaScript, TypeScript, JSX, GraphQL, JSON, CSS, SCSS, Less, ...
in terminal
- run
yarn prettier
(see"scripts"
section inpackages.json
)
- run
for Atom:
- install prettier-atom plugin
- remember to:
- open
.prettierignore
and.prettierrc.yaml
when using with Remote FTP plugin - turn on "Format File on Save"
- open
- maybe you will need global installation of Prettier on your machine
npm install --global prettier@2.1.2
other editors:
- see "Editor Support" section on Prettier homepage or use Google
.prettierrc.yaml
example:
React Inputs
React Forms - Formik
library for handling forms in React
validations:
- form state
- data "wiring" (React Context)
- validation
- array fields + dynamic fields
- wizards
- and much more...
Formik Validations
Reusable Field with useField
Hook
Formik Limits
file upload
- no native support for file inputs
- there are workarounds
number of inputs (100+ inputs on one page):
- could become slow
- there are workarounds
Google it or use other form libraries for React
if in doubt contact me using MS Teams to: Tomas Horacek (@hort19)