Skip to content

Instantly share code, notes, and snippets.

@pubudu-ranasinghe
Created November 2, 2019 16:13
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
react-context-example-05
import React, { useState } from "react";
export function NewItem({ add }) {
const [text, setText] = useState("");
return (
<div className="Item">
<input
type="text"
placeholder="New Task"
value={text}
onChange={e => setText(e.target.value)}
></input>
<button onClick={() => add(text)}>Add</button>
</div>
);
}
// Rest of the components
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment