From dca444208df23dc6e95689b4d1f03ae89088c503 Mon Sep 17 00:00:00 2001 From: Abhas Date: Thu, 3 Jan 2019 16:44:56 +0530 Subject: [PATCH] Call getTodos only once in render --- src/App2.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/App2.js b/src/App2.js index 42efc0c..4a3bf17 100644 --- a/src/App2.js +++ b/src/App2.js @@ -46,13 +46,15 @@ export default class App extends Component { } render() { + const todos = this.getTodos(); + return (
this.setTodos([{ text, complete: false }, ...this.getTodos()])} + onSubmit={text => this.setTodos([{ text, complete: false }, ...todos])} />
- {this.getTodos().map(({ text, complete }, i) => ( + {todos.map(({ text, complete }, i) => (
this.toggleComplete(i)}