docs: add connect factory props example#286
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new example of a Redux connected component using a factory for mapStateToProps to demonstrate per-instance memoization. The changes include documentation updates in README.md and README_SOURCE.md, the implementation of the factory-based connected component in fc-counter-connected-factory.tsx, and a corresponding usage example. A review comment identifies a missing label property in the OwnProps type definition, which is required for type compatibility with the underlying FCCounter component.
| type OwnProps = { | ||
| initialCount?: number; | ||
| }; |
There was a problem hiding this comment.
The OwnProps type is missing the label property, which is required by the FCCounter component. Since label is passed to the connected component in the usage example but not provided by mapStateToProps or mapDispatchToProps, it must be included in OwnProps to ensure type safety and avoid a compilation error when calling connect.
| type OwnProps = { | |
| initialCount?: number; | |
| }; | |
| type OwnProps = { | |
| label: string; | |
| initialCount?: number; | |
| }; |
|
Follow-up pushed in 136a34d to address the Gemini review note: the connected factory example's OwnProps now includes the required label prop, and README.md was regenerated from the source example.\n\nValidation: npm run ci-check passed, including doctoc/readme generation and the pre-push clean-worktree check. |
Summary
MapStateToPropsFactoryownPropswhile keeping inferred connected props type-safeREADME_SOURCE.mdand regenerateREADME.mdFixes #91
IssueHunt bounty: https://oss.issuehunt.io/r/piotrwitek/react-redux-typescript-guide/issues/91
Verification
npm run ci-checkcd playground && npm run lintcd playground && npm run tsccd playground && CI=true npm test -- --watchAll=falsegit diff --checkIssueHunt Summary
Referenced issues
This pull request has been submitted to: