问题描述
我正在将antd pro v5与graphql一起使用。
我已经定义了布局ApolloLayout
export class ApolloLayout extends React.Component<IProps,{}> {
constructor(props: IProps) {
super(props);
}
render() {
return (
<>
<ApolloProvider client={client}>{this.props.children}</ApolloProvider>
</>
);
}
}
并将ApolloLayout
包裹在pages/contacts/index.tsx
...
return (
<>
<ApolloLayout>
<PageContainer>
...
<CreateGroupForm name={value} unsetForm={() => setGroupEditable(false)} />
...
</PageContainer>
</ApolloLayout>
</>
);
我的pages/contacts/CreateGroupForm.tsx
是
const AddGroupForm: React.FC<AddGroupProps & FormikProps<AddGroupValues> & any> = ({
...
...
...
})
export default compose(
withApollo,withFormik<AddGroupProps,AddGroupValues>({
enableReinitialize: true,mapPropsTovalues: ({ id,name,create,unsetForm }) => {
return {
name,};
},validationSchema: Yup.object().shape({
name: Yup.string().required('Group name is required'),}),handleSubmit: (values,formikBag) => {
console.log(values);
},withCreateContactGroup()
)(AddGroupForm);
withCreateContactGroup
是由graphql-codegen临时生成的
但我遇到错误
Invariant Violation: Could not find "client" in the context or passed in as an option. Wrap the root component in an <ApolloProvider>,or pass an ApolloClient instance in via options.
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)