Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bindActionCreators example is outdated #203

Open
@gocreating

Description

@gocreating

Theexample ofbindActionCreators does not pass generic parameters. Either, optionally pass only one generic parameter:bindActionCreators<ActionCreatorsMapObject<Types.RootAction>>.

Without generic parameters, react component will report not assignable error. The latest redux's bindActionCreators also accepts exact 2 generic parameters. So the example seems outdated.

My current workaround isbindActionCreators<any, any>:

const mapStateToProps = (state: RootState) => ({  ...});const mapDispatchToProps = (dispatch: Dispatch<RootAction>) => bindActionCreators<any, any>({  ...}, dispatch);type Props = ReturnType<typeof mapStateToProps> & ReturnType<typeof mapDispatchToProps>

But theProps is then inferred as typeany, which is unacceptable for me.
If I change tobindActionCreators<any, ActionCreatorsMapObject<RootAction>>, then my react component starts to report not assignable error again...

const MyComponent: React.FunctionComponent<Props> = ({ ... }) => {  ...};MyComponent.propTypes = {  ...};export default connect(mapStateToProps, mapDispatchToProps)(MyComponent);

I am really confused about the correct usage ofbindActionCreators.
Anyone can help? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp