Skip to content

Instantly share code, notes, and snippets.

@sumitkharche
Created May 9, 2020 14:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sumitkharche/7c5fcbc8d4b3e375bfb1debd9adf3b2d to your computer and use it in GitHub Desktop.
Save sumitkharche/7c5fcbc8d4b3e375bfb1debd9adf3b2d to your computer and use it in GitHub Desktop.
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