Skip to content

Commit 7692b29

Browse files
committed
extract getStyles from render
1 parent 27cde47 commit 7692b29

File tree

1 file changed

+6
-2
lines changed
  • chapter-10/todo_react_motion/src/todos/views

1 file changed

+6
-2
lines changed

chapter-10/todo_react_motion/src/todos/views/todoList.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const willEnter = () => {
1919
};
2020
};
2121

22-
const TodoList = ({todos}) => {
23-
const styles = todos.map(item => {
22+
const getStyles = (todos) => {
23+
return todos.map(item => {
2424
return {
2525
key: item.id.toString(),
2626
data: item,
@@ -30,7 +30,11 @@ const TodoList = ({todos}) => {
3030
}
3131
};
3232
});
33+
}
3334

35+
36+
const TodoList = ({todos}) => {
37+
const styles = getStyles(todos);
3438
return (
3539
<TransitionMotion
3640
willLeave={willLeave}

0 commit comments

Comments
 (0)