Skip to content

Commit

Permalink
readme cleanup etc
Browse files Browse the repository at this point in the history
  • Loading branch information
adg29 committed Nov 8, 2019
1 parent 1ce9f0c commit 6306f64
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# easy-peasy-typescript
# easy-peasy-typescript + `react-hook-form`

This is an example implementation of using Typescript with [Easy Peasy](https://github.com/ctrlplusb/easy-peasy). This grants you a fully typed global state solution for React, which abstracts all of the Redux boilerplate whilst still granting you access to all of its power.
An example implementation of using Typescript with [react-hook-form](https://github.com/react-hook-form/react-hook-form) and [Easy Peasy](https://github.com/ctrlplusb/easy-peasy).

## Getting started
React Hook Form is built based on uncontrolled input, which means you don't need to change input value via state by onChange. Registering forn inputs ensures that `react-hook-form`'s `handleSubmit` function will receive the form data when form validation is successful.

```
git clone https://github.com/ctrlplusb/easy-peasy-typescript
cd easy-peasy-typescript
npm install
npm start
```
The fully typed global state solution for React abstracts Redux boilerplate, and also grants access to all of its power.

## `react-hook-form` supporting documentation

- Uncontrolled Components in React https://reactjs.org/docs/uncontrolled-components.html
- `register` and `handleSubmit` API docs https://react-hook-form.com/api#register
8 changes: 0 additions & 8 deletions src/components/todos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,7 @@ export default function Todos() {
}
});

// // Reset the form state every time the todo items changes
// useEffect(() => {
// console.log('items change')
// console.log(items)
// setValue('descriptionRequired', "")
// }, [items]);

const onSubmit = (hookFormData: any, e: { target: { reset: () => void; }; }) => {
console.log(hookFormData)
add(hookFormData.descriptionRequired);
e.target.reset();
};
Expand Down

0 comments on commit 6306f64

Please sign in to comment.