import * as React from 'react';
export const AuthRoute = () => (WrappedComponent: any) => {
return class extends React.Component<{}, {}> {
constructor(props: any) {
super(props);
}
public render() {
return <WrappedComponent {...this.props} />;
}
};
}
我希望这个HOC能够访问另一个HOC——React Apollo client HOC for GraphQL。我试过在这个HOC上使用Apollo客户机,但它给出了一个错误“TypeError:Cannot set property'props'of undefined”。我的尝试是:
const AuthRoute = () => (WrappedComponent: any) => {
return class extends React.Component<{}, {}> {
constructor(props: any) {
super(props);
}
public render() {
return <WrappedComponent {...this.props} />;
}
};
}
const GET_AUTH = gql`
{
authStatus {
authStatus
}
}
`;
export default compose(graphql(GET_AUTH))(AuthRoute);
谢谢!