react-redux-typescript-guide icon indicating copy to clipboard operation
react-redux-typescript-guide copied to clipboard

State type inferrence

Open shaun-sweet opened this issue 5 years ago • 3 comments

Currently the guide has for react components the state type defined up with the props. Instead, I propose its changed to be flipped a bit. For example ->

type ownProps = {}
const initialState = {
  isOpen: false
}

class Modal extends React.Component<ownProps, typeof initialState> {
  state = initialState

this better follows the repositories philosophy of implementation being the source of truth

shaun-sweet avatar Jul 08 '19 17:07 shaun-sweet

Sounds good, could be added as an alternative approach to the guide in the Class components section.

piotrwitek avatar Jul 08 '19 22:07 piotrwitek

cool, i'll submit a PR

shaun-sweet avatar Jul 09 '19 04:07 shaun-sweet

@shaun-sweet sure go for it. Please try to keep as much consistency as possible in terms of guide structure and naming/casing conventions across the examples.

piotrwitek avatar Jul 09 '19 07:07 piotrwitek