Skip to content

Instantly share code, notes, and snippets.

@jamesplease jamesplease/react.js
Last active Mar 29, 2019

Embed
What would you like to do?
Defining a variable in JS vs React wit hooks
// JavaScript
const thing = {};
// React wit hooks
import { useState, useRef, useEffect } from 'react';
const [thing, setThing] = useState();
const thingRef = useRef(thing);
useEffect(() => {
thingRef.current = thing;
}, [thing]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.