Skip to content

Instantly share code, notes, and snippets.

@Yamo93
Last active July 18, 2022 16:01
Show Gist options
  • Save Yamo93/10f27daf625925e2c80ea51c57bc12bb to your computer and use it in GitHub Desktop.
Save Yamo93/10f27daf625925e2c80ea51c57bc12bb to your computer and use it in GitHub Desktop.
function Parent () {
function save (text) {
server.save(text); // save text on server
}
return <Window onSave={(text) => save(text)}} />;
}
function Window ({ onSave }) {
const [text, setText] = useState('');
return <div>
<label>Text:</label>
<input type="text" value={text} onChange={(e) => setText(e.target.value)} />
<button onClick={() => onSave(text)}>Save</button>
</div>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment