@flywire/react-hooks
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -11,2 +11,12 @@ # Changelog | ||
## [0.0.5] - 2020-06-12 | ||
### Changed | ||
- Add example using useToggle | ||
### Fixed | ||
- Export useToggle | ||
## [0.0.4] - 2020-06-12 | ||
@@ -13,0 +23,0 @@ |
{ | ||
"name": "@flywire/react-hooks", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "A collection of Reacts hooks used in Flywire", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -13,39 +13,25 @@ # useForm | ||
| Key | Description | | ||
| :-------------------- | :------------------------------------------------ | | ||
| `defaultValues` | Initial values of the fields. Default = {} | | ||
| Key | Description | | ||
| :-------------- | :----------------------------------------- | | ||
| `defaultValues` | Initial values of the fields. Default = {} | | ||
#### Return object | ||
| Key | Description | | ||
| :-------------------- | :------------------------------------------------ | | ||
| `values` | Field values | | ||
| `dirtyFields` | Fields modified by the user | | ||
| `handleChange` | Callback for persisting the field's value | | ||
| Key | Description | | ||
| :------------- | :---------------------------------------- | | ||
| `values` | Field values | | ||
| `dirtyFields` | Fields modified by the user | | ||
| `handleChange` | Callback for persisting the field's value | | ||
#### Usage | ||
#### Usage | ||
```jsx harmony | ||
import React from 'react'; | ||
import { useForm } from '@flywire/react-hooks'; | ||
import { useToggle } from '@flywire/react-hooks'; | ||
function App() { | ||
const { values, handleChange, dirtyValues } = useForm(); | ||
const [on, toggle] = useToggle(); | ||
function handleSubmit(evt) { | ||
evt.preventDefault(); | ||
} | ||
function handleInputChange(evt) { | ||
handleChange(evt.target.name, evt.target.value); | ||
} | ||
return ( | ||
<form onSubmit={handleSubmit}> | ||
<input name="firstname" onChange={handleInputChange} /> | ||
{!values.firstName && dirtyValues.firstName && 'First name is required.'} | ||
<input type="submit" /> | ||
</form> | ||
); | ||
return <button onClick={toggle}>{on ? 'ON' : 'OFF'}</button>; | ||
} | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28
397
18433