Skip to content

Add @connect decorator TypeScript example - #357

Open
libracapitalinvestments-rgb wants to merge 1 commit into
piotrwitek:masterfrom
libracapitalinvestments-rgb:casharmy/fix-issue-68
Open

Add @connect decorator TypeScript example#357
libracapitalinvestments-rgb wants to merge 1 commit into
piotrwitek:masterfrom
libracapitalinvestments-rgb:casharmy/fix-issue-68

Conversation

@libracapitalinvestments-rgb

Copy link
Copy Markdown

Adds a documented example showing how to use the @connect(..) decorator syntax with TypeScript for class components, including proper typing of own props vs connected props. Closes #68

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors and simplifies the React & Redux in TypeScript guide, focusing on modern type-checking patterns for functional and class components, Redux integration, and configuration. It also introduces examples for using the @connect decorator with class components. Feedback on the changes points out that the newly added CounterWithDecorator component in docs/src/connected-class-components/with-connect-decorator.tsx should be cast to React.ComponentType<OwnProps> upon export to prevent TypeScript from requiring consumers to provide Redux-injected props.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

}
}

export default CounterWithDecorator;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Without casting the exported component, TypeScript will require consumers of CounterWithDecorator to provide all props (including count, onIncrement, and onDecrement which are injected by Redux). To fix this, cast the exported component to React.ComponentType<OwnProps> so that only OwnProps are required by parent components.

Suggested change
export default CounterWithDecorator;
export default CounterWithDecorator as React.ComponentType<OwnProps>;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@connect decorator

1 participant