Skip to content

Instantly share code, notes, and snippets.

@JaysonChiang
Created March 2, 2021 00:54
Show Gist options
  • Save JaysonChiang/c048fb009d7a01df30a9b4c96d72a183 to your computer and use it in GitHub Desktop.
Save JaysonChiang/c048fb009d7a01df30a9b4c96d72a183 to your computer and use it in GitHub Desktop.
useSelector without DefaultRootState
import { combineReducers } from 'redux';
import todosReducer from './todosReducer';
const reducers = combineReducers({
todos: todosReducer,
});
export default reducers;
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