Skip to content

Instantly share code, notes, and snippets.

@jmaicaaan
Last active May 31, 2020 09:51
Show Gist options
  • Save jmaicaaan/3c1b43a1ead857799315f1034c369ef4 to your computer and use it in GitHub Desktop.
Save jmaicaaan/3c1b43a1ead857799315f1034c369ef4 to your computer and use it in GitHub Desktop.
[DEMO] Transformers For ReactJs
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