Skip to content

Instantly share code, notes, and snippets.

@mikekoro
Last active May 9, 2020 05:46
Show Gist options
  • Save mikekoro/aee12e94eee0c946938fd1853001e9a4 to your computer and use it in GitHub Desktop.
Save mikekoro/aee12e94eee0c946938fd1853001e9a4 to your computer and use it in GitHub Desktop.
Re-useable Custom Hook
// useValue.js
import React, { useState } from 'react';
export const useValue = (initial_value) => {
const [value, setValue] = useState(initial_value);
const assignValue = (input) => {
setValue(input);
}
return { value, assignValue };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment