1.8.0-alpha.11 • Published 6 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-formUsage
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
6 years ago
1.8.0-alpha.10
6 years ago
1.8.0-alpha.8
6 years ago
1.8.0-alpha.9
6 years ago
1.8.0-alpha.2
6 years ago
1.8.0-alpha.3
6 years ago
1.8.0-alpha.1
6 years ago
1.7.0
6 years ago
1.8.0-alpha.6
6 years ago
1.8.0-alpha.7
6 years ago
1.8.0-alpha.4
6 years ago
1.8.0-alpha.5
6 years ago
1.8.0-alpha
6 years ago
1.6.2
6 years ago
1.6.1
6 years ago
1.6.0
6 years ago
1.5.0
6 years ago
1.4.0
6 years ago
1.3.0
6 years ago
1.2.0
6 years ago
1.1.0
6 years ago
1.0.0
6 years ago