Skip to content

Instantly share code, notes, and snippets.

View jeanbauer's full-sized avatar

Jean jeanbauer

View GitHub Profile
@jeanbauer
jeanbauer / Error description
Created January 6, 2019 10:38
Invariant Violation: Hooks can only be called inside the body of a function component.
Invariant Violation: Hooks can only be called inside the body of a function component.
2 |
3 | export function useFormField(initialValue) {
> 4 | const [value, setValue] = useState(initialValue)
| ^
5 |
6 | function onChange(e) {
7 | setValue(e.target.value)
@jeanbauer
jeanbauer / example.js
Created December 23, 2018 02:00
[REQUEST FOR FEEDBACK]: How to subscribe to realtime data using Firebase Collections and React Hooks
// Usage - client:
useEffect(() => {
subscribe('users', setUsers)
subscribe('messages', setMessages)
}
// Subscribe implementation
export function subscribe(collection, onDataReceive) {
db.collection(collection)
@jeanbauer
jeanbauer / form.js
Created December 16, 2018 01:15
Text Input using react hooks with a custom hook: useFormInput
import { useState } from 'react'
const Form = () => {
const name = useFormInput('Name')
return (
<>
<input {...name} />
</>
)

Keybase proof

I hereby claim:

  • I am jeanbauer on github.
  • I am jeanbauer (https://keybase.io/jeanbauer) on keybase.
  • I have a public key ASDC4KuyhEyvQCn_yguIMXgHN7XotjmC8_slacrZ22sHWgo

To claim this, I am signing this object:

### Keybase proof
I hereby claim:
* I am jeanbauer on github.
* I am jeanbauer (https://keybase.io/jeanbauer) on keybase.
* I have a public key ASDC4KuyhEyvQCn_yguIMXgHN7XotjmC8_slacrZ22sHWgo
To claim this, I am signing this object: