1.8.0-alpha.11 • Published 4 years ago
use-mui-rich-form v1.8.0-alpha.11
use-mui-rich-form
An opinionated react hook to make it easier to work with form stats (processing/success/failure) with material-ui and react-hook-forms and that features ready to use Mui components.
Install
npm install --save use-mui-rich-form
Usage
import React from 'react';
import * as Mui from "@material-ui/core";
import { useMuiRichForm, Form, Field, CircularButton } from 'use-mui-rich-form';
import SaveIcon from "@material-ui/icons/Save";
const Example = () => {
const richForm = useMuiRichForm();
const onSubmit = async (values) => {
richForm.setProcessing();
try {
await doStuff();
richForm.setSuccess('stuff done');
} catch (e) {
console.error(e);
richForm.setFailure('Something went wrong');
}
}
return (
<div>
<Form richForm={richForm} onSubmit={onSubmit}>
<Field error={richForm.error.someText}>
<Miu.TextField id="some_text" label="Some Text" {...richForm.textField('someText', {required: true})} />
</Field>
<CircularButton {...richForm.submitButton()} icon={<SaveIcon />} />
{ richForm.success }
{ richForm.failure }
</Form>
</div>
)
}
License
MIT © gsouf
This hook is created using create-react-hook.
1.8.0-alpha.11
4 years ago
1.8.0-alpha.10
4 years ago
1.8.0-alpha.8
4 years ago
1.8.0-alpha.9
4 years ago
1.8.0-alpha.2
4 years ago
1.8.0-alpha.3
4 years ago
1.8.0-alpha.1
4 years ago
1.7.0
4 years ago
1.8.0-alpha.6
4 years ago
1.8.0-alpha.7
4 years ago
1.8.0-alpha.4
4 years ago
1.8.0-alpha.5
4 years ago
1.8.0-alpha
4 years ago
1.6.2
4 years ago
1.6.1
4 years ago
1.6.0
4 years ago
1.5.0
4 years ago
1.4.0
4 years ago
1.3.0
4 years ago
1.2.0
4 years ago
1.1.0
4 years ago
1.0.0
4 years ago