Component - Redux selectors
This UI component shows how Redux selectors help get specific data from the app's state in a React Native app. It displays a list of items from the store and updates when the store changes.
This UI component shows how Redux selectors help get specific data from the app's state in a React Native app. It displays a list of items from the store and updates when the store changes.
App ├── Provider │ └── ItemList │ ├── View │ │ ├── Text (Title) │ │ └── FlatList │ │ └── renderItem -> Text (Item name) │ └── Button (Refresh)
selectUser that returns state.user?state parameter.state.user directly. Arrow function with implicit return is correct.const selectCompletedTodos = state => state.todos.filter(todo => todo.completed); and the state { todos: [{id:1, completed:true}, {id:2, completed:false}, {id:3, completed:true}] }, what will selectCompletedTodos(state) return?completed is true.completed:true, so they are included.const selectUserName = state => { state.user.name }return to return state.user.name.reselect to get the count of completed todos from state. Which code correctly implements this?createSelector function is imported from 'reselect' and used properly.selectTodos gets todos array; output function filters completed and counts them.const selectCompletedCount = state => state.todos.filter(todo => todo.completed).length is not memoized; importing createSelector from 'redux' is wrong; todos => todos.completed.length accesses property incorrectly.Pass the test and this pattern moves unknown