Last active
May 31, 2020 09:51
-
-
Save jmaicaaan/3c1b43a1ead857799315f1034c369ef4 to your computer and use it in GitHub Desktop.
[DEMO] Transformers For ReactJs
This file contains hidden or 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
export const App = () => { | |
const [todos, setTodos] = useState([]); | |
useEffect(() => { | |
const getTodos = async () => { | |
const { data } = await axios.get('https://jsonplaceholder.typicode.com/todos/'); | |
setTodos(data); | |
}; | |
getTodos(); | |
}, []); | |
return ( | |
<div> | |
<TodoList | |
todos={todos} | |
/> | |
</div> | |
); | |
}; | |
const TodoList = ({ | |
todos | |
}) => ( | |
<div> | |
<h1>Todo List</h1> | |
<ul> | |
{todos.map((todo) => ( | |
<li | |
key={todo.id} | |
style={{ | |
textDecoration: todo.isCompleted ? 'line-through' : 'none' | |
}} | |
> | |
{todo.title} | |
</li> | |
))} | |
</ul> | |
</div> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment