Created
October 23, 2018 16:40
-
-
Save valex/18104b2dc07e3efbec381f4ef8a2d22d to your computer and use it in GitHub Desktop.
textarea
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>textarea</title> | |
<meta charset="utf-8"> | |
</head> | |
<body> | |
<div id="app1"></div> | |
<div id="app2"></div> | |
<div id="app3"></div> | |
<div id="app4"></div> | |
<script charset="utf-8" crossorigin src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script> | |
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script> | |
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script> | |
<script type="text/babel"> | |
function log(event) { | |
console.log("value: ", event.target.value); | |
console.log("defaultValue: ", event.target.defaultValue); | |
} | |
ReactDOM.render( | |
<textarea defaultValue="hello\nworld" onChange={log} />, | |
document.getElementById('app1') | |
); | |
ReactDOM.render( | |
<textarea defaultValue={"hello\nworld"} onChange={log} />, | |
document.getElementById('app2') | |
); | |
ReactDOM.render( | |
<textarea onChange={log}>hello | |
world | |
</textarea>, | |
document.getElementById('app3') | |
); | |
ReactDOM.render( | |
<textarea onChange={log}>{"hello\n\ | |
world"} | |
</textarea>, | |
document.getElementById('app4') | |
); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment