Skip to content

Instantly share code, notes, and snippets.

@hiro08gh
Last active September 2, 2019 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiro08gh/ce8bf5da3e4b2da71c9ee4ee20c218c3 to your computer and use it in GitHub Desktop.
Save hiro08gh/ce8bf5da3e4b2da71c9ee4ee20c218c3 to your computer and use it in GitHub Desktop.
値を変更するhooks part2
import React, {useState} from 'react';
const useInput = (initialValue) => {
const [name, setVName] = setState(initialValue);
const onChange = (e) => {
setValue(e.target.value);
}
return [value, onChange];
}
//使い方
//const [name, setName] = setInput('');
//<input type="text" name="name" value={name} onChange={setName} />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment