-
Notifications
You must be signed in to change notification settings - Fork 135
Closed
Labels
Description
I suggest a connect component for ui-router-react be provided since accessing context directly isn't ideal. Something like:
import React, {Component} from 'react';
import PropTypes from 'prop-types';
const ConnectWithRouter = (params = (router) => ({router})) => (WrappedComponent) => {
class connector extends Component {
static contextTypes = {
router: PropTypes.object
};
constructor(props, context) {
super(props, context);
this.context = context;
}
render() {
return <WrappedComponent {...params(this.context.router)} {this.props} />
}
return connector;
}
}
return ConnectWithRouter;
Sorry I'd make a PR but I am not familiar enough with TypeScript.