Skip to content

redux怎么在react写typescript类型 #1

Description

@GeSnowBoy

关键代码

关键代码
const mapStateToProps = state => {
  return {
    msg: '你好世界测试'
  };
};

const mapDispatchToProps = props => {
  return {
    ceshi() {}
  };
};

interface P
  extends ReturnType<typeof mapStateToProps>,
    ReturnType<typeof mapDispatchToProps> {
    
    }

全部代码示例

import * as React from 'react';
import { connect } from 'react-redux';
const mapStateToProps = state => {
  return {
    msg: '你好世界测试'
  };
};

const mapDispatchToProps = props => {
  return {
    ceshi() {}
  };
};

interface P
  extends ReturnType<typeof mapStateToProps>,
    ReturnType<typeof mapDispatchToProps> {
    
    }
function IndexPage(props: P) {
  return <div>{props.msg}</div>;
}
export default connect(
  mapStateToProps,
  mapDispatchToProps
)(IndexPage);

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions