Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@brightleaf/react-hooks

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@brightleaf/react-hooks - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

2

package.json
{
"name": "@brightleaf/react-hooks",
"version": "0.2.1",
"version": "0.2.2",
"description": "Useful react hooks",

@@ -5,0 +5,0 @@ "files": [

@@ -5,2 +5,10 @@ # Brightleaf React Hooks

* `useFetch` - Hook to use Fetch
* `useGet` - Hook to make a get request
* `usePost` - Hook to make an HTTP Post
* `useClickOutside` - Hook to handle a click outside an element
* `useGraphQL` - Hook to make a GraphQL request
* `useNes` - Hook to connect to Hapijs NES
* `useWebSockets` - Hook to interact with WebSockets
## GraphQL Hook

@@ -10,7 +18,7 @@

import React, { useState } from 'react'
import { useQuery } from '@brightleaf/hooks'
import { useGraphQL } from '@brightleaf/hooks'
export default () => {
const [id, setId] = useState(1)
const { data, loading, error } = useQuery(
const { data, loading, error } = useGraphQL(
'https://swapiql.herokuapp.com/graphql',

@@ -66,2 +74,44 @@ `query Person($id: ID) {

```
```
## Get Hook
```javascript
import React, { useState } from 'react'
import { useGet } from '@brightleaf/react-hooks'
export default () => {
const [id, setId] = useState(1)
const { data, error, loading } = useGet(
`https://swapiql.herokuapp.com/api/characters/${id}`
)
if (error) {
return (
<div className="App">
<h1>Error Getting Data</h1>
</div>
)
}
if (loading) {
return (
<div className="App">
<h1>Loading Data</h1>
</div>
)
}
return (
<div className="App">
<h1>{data[0].name}</h1>
<h2>Pick a number</h2>
<div className="select">
<div
onClick={e => {
setId(2)
}}
>
2
</div>
</div>
</div>
)
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc