Created
May 9, 2020 14:27
-
-
Save sumitkharche/7c5fcbc8d4b3e375bfb1debd9adf3b2d to your computer and use it in GitHub Desktop.
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'; | |
import './App.css'; | |
import { Stack } from "@fluentui/react"; | |
import TodoList from './components/TodoList'; | |
import AddTodo from './components/AddTodo'; | |
function App() { | |
const [todos, setTodos] = useState([{ id: 1, name: "Todo Item 1" }, { id: 2, name: "Todo Item 2" }]); | |
const addTodo = (todoName: string) => { | |
if (todoName != "") { | |
const newId = todos.length + 1; | |
const newTodos = [...todos, { id: newId, name: todoName }]; | |
setTodos(newTodos); | |
} | |
}; | |
return ( | |
<div className="wrapper"> | |
<Stack horizontalAlign="center"> | |
<h1>Todo App using Fluent UI & React</h1> | |
<Stack style={{ width: 300 }} gap={25}> | |
<AddTodo addTodo={addTodo} /> | |
<TodoList todos={todos} /> | |
</Stack> | |
</Stack> | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment