Created
March 2, 2021 00:54
-
-
Save JaysonChiang/c048fb009d7a01df30a9b4c96d72a183 to your computer and use it in GitHub Desktop.
useSelector without DefaultRootState
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { combineReducers } from 'redux'; | |
import todosReducer from './todosReducer'; | |
const reducers = combineReducers({ | |
todos: todosReducer, | |
}); | |
export default reducers; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useSelector } from 'react-redux'; | |
const TodoList: React.FC = () => { | |
const { todos } = useSelector((state) => state.todos); | |
// Property 'todos' does not exist on type 'DefaultRootState'. | |
return ( | |
<ul> | |
{todos.map((todo) => ( | |
<li>{todo}</li> | |
))} | |
</ul> | |
); | |
}; | |
export default TodoList; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment