Skip to content

Instantly share code, notes, and snippets.

@eddyw
Created February 5, 2018 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eddyw/26289329fd9fd774bffe074370d37249 to your computer and use it in GitHub Desktop.
Save eddyw/26289329fd9fd774bffe074370d37249 to your computer and use it in GitHub Desktop.
Type-checking Redux State with propTypes (without React)
import TodoReducer from 'TodoReducer'
import { createStore } from 'redux'
const store = createStore(TodoReducer)
store.dispatch({
type: 'ADD_TODO',
payload: {
title: 'Example',
done: 1,
},
})
// Console Outputs:
// Warning: Failed property type: Invalid property `state[0].done`
// of type `number` supplied to `TodoReducer`, expected `boolean`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment