Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kdy1/react-forms
Smart validation for react
https://github.com/kdy1/react-forms
Last synced: 26 days ago
JSON representation
Smart validation for react
- Host: GitHub
- URL: https://github.com/kdy1/react-forms
- Owner: kdy1
- Created: 2020-03-17T13:21:20.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-03-26T09:26:37.000Z (almost 5 years ago)
- Last Synced: 2024-12-06T23:10:24.319Z (29 days ago)
- Language: TypeScript
- Size: 13.7 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# React form
## Usage
### Simple usage
If you **don't use** forms from `@material-ui/core`, run
```js
npm i -S react-forms-base
``````ts
// TODO
```### Material form fields
If you **use** `@material-ui/core`, you can easily add validation logic to a `TextField`.
```js
npm i -S react-forms-base react-material-fields
``````ts
import { Form } from "react-forms-base";
import { useFormState } from "react-use-form-state";
import { TextFormField } from "react-material-fields/lib/TextFormField";const MyForm: React.FC = () => {
// This part is optional. You can your own `onChange` and `value`.
const [form, { text }] = useFormState({});return (
{
if (!v) {
return "Enter name of the app";
}
}}
/>{
if (!v) return "Please enter id of the app";
if (v.length < 3)
return "ID of the app should be at least 3 characters";
}}
/>Create
);
};
```![Validation of id](./validation.png)