【发布时间】:2019-05-13 05:47:20
【问题描述】:
所以基本上我的功能组件有 mapStateToProps 和 mapDispatchToProps 的连接功能,但是如果我尝试访问道具 typescript 会抛出错误
const Navbar: FC = ({ route, doChangeRoute }) => {
//... code here bla bla
}
const mapStateToProps = ({ routeReducer }: AppState) => {
const { route } = routeReducer;
return { route };
};
const mapDispatchToProps = dispatch => bindActionCreators({ doChangeRoute }, dispatch);
export default connect(
mapStateToProps,
mapDispatchToProps,
)(Navbar);
// ERROR: Property 'route' does not exist on type '{ children?: ReactNode; }'. TS2339
【问题讨论】:
标签: reactjs typescript redux