Skip to content

Instantly share code, notes, and snippets.

@pubudu-ranasinghe
Created November 2, 2019 16:13
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 pubudu-ranasinghe/77926f57060108410f1e6450c04a0424 to your computer and use it in GitHub Desktop.
Save pubudu-ranasinghe/77926f57060108410f1e6450c04a0424 to your computer and use it in GitHub Desktop.
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