TaskList: convert to a pure functional component.

master
Tom Hacohen 5 years ago
parent 1d792add0f
commit ec5d1faaa1

@ -26,14 +26,13 @@ const sortSelector = createSelector(
(entries) => entries.sort((a, b) => a.title.localeCompare(b.title))
);
class TaskList extends React.PureComponent {
public props: {
interface PropsType {
entries: TaskType[];
onItemClick: (entry: TaskType) => void;
};
}
public render() {
const entries = this.props.entries.filter((x) => !x.finished);
export default React.memo(function TaskList(props: PropsType) {
const entries = props.entries.filter((x) => !x.finished);
const sortedEntries = sortSelector(entries);
const itemList = sortedEntries.map((entry) => {
@ -43,7 +42,7 @@ class TaskList extends React.PureComponent {
<TaskListItem
key={uid}
entry={entry}
onClick={this.props.onItemClick}
onClick={props.onItemClick}
/>
);
});
@ -53,7 +52,4 @@ class TaskList extends React.PureComponent {
{itemList}
</List>
);
}
}
export default TaskList;
});

Loading…
Cancel
Save