Last active
September 2, 2019 13:34
-
-
Save hiro08gh/ce8bf5da3e4b2da71c9ee4ee20c218c3 to your computer and use it in GitHub Desktop.
値を変更するhooks part2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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