@brightleaf/react-hooks
Advanced tools
Comparing version 5.0.0 to 5.1.0
@@ -54,2 +54,8 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "useForm", { | ||
enumerable: true, | ||
get: function () { | ||
return _useForm.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useGet", { | ||
@@ -180,2 +186,4 @@ enumerable: true, | ||
var _useForm = _interopRequireDefault(require("./use-form")); | ||
var _useGet = _interopRequireDefault(require("./use-get")); | ||
@@ -182,0 +190,0 @@ |
{ | ||
"name": "@brightleaf/react-hooks", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"description": "Useful react hooks", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -7,2 +7,3 @@ # Brightleaf React Hooks | ||
* [`useFetch`](#fetch-hook) - Hook to use Fetch | ||
* [`useForm`](#form-hook) - Hook to make using forms super easy | ||
* [`useGet`](#get-hook) - Hook to make a get request | ||
@@ -86,2 +87,70 @@ * [`usePost`](#post-hook) - Hook to make an HTTP Post | ||
## Form Hook | ||
```javascript | ||
import React, { useState } from 'react' | ||
import { useForm } from '@brightleaf/react-hooks' | ||
export default () => { | ||
const { addToForm, onSubmit } = useFetch() | ||
return ( | ||
<form | ||
onSubmit={onSubmit(data => { | ||
console.info('onsubmit handler', data) | ||
})} | ||
> | ||
<fieldset> | ||
<legend>Form Hook</legend> | ||
<input | ||
name="firstName" | ||
type="text" | ||
ref={addToForm} | ||
defaultValue="Brightleaf" | ||
/> | ||
<input | ||
name="lastName" | ||
type="text" | ||
ref={addToForm} | ||
defaultValue="Hooks" | ||
/> | ||
<br /> | ||
<select ref={addToForm} name="dropdown" defaultValue="13"> | ||
<optgroup label="First Group"> | ||
<option value="1">First</option> | ||
<option value="2">Second</option> | ||
<option value="3">Third</option> | ||
</optgroup> | ||
<optgroup label="Second Group"> | ||
<option value="11">Second First</option> | ||
<option value="12">Second Second</option> | ||
<option value="13">Second Third</option> | ||
</optgroup> | ||
</select> | ||
<br /> | ||
<input type="checkbox" name="check" defaultChecked ref={addToForm} /> | ||
<br /> | ||
<div> | ||
<label>The Radio</label> | ||
<div> | ||
<label> First </label> | ||
<input name="rgroup" type="radio" value="first" ref={addToForm} /> | ||
</div> | ||
<div> | ||
<label> Second </label> | ||
<input | ||
name="rgroup" | ||
type="radio" | ||
value="second" | ||
ref={addToForm} | ||
/> | ||
</div> | ||
</div> | ||
<br /> | ||
<button type="submit">Submit</button> | ||
</fieldset> | ||
</form> | ||
) | ||
} | ||
``` | ||
## GraphQL Hook | ||
@@ -88,0 +157,0 @@ |
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
75128
41
2011
689