apollo-client

Cache data may be lost when replacing the my field of a Query object

谁说我不能喝 提交于 2021-01-04 08:00:06
问题 this my code const NewVerificationCode = () => { const { loading, error, data = {}, refetch } = useQuery(CONFIRMATION_CODE, { skip: true, onError: (err) => {}, }); console.log(loading, error, data); if (loading || error) { return <ErrorLoadingHandler {...{ loading, error }} />; } return ( <form onSubmit={(e) => { refetch(); e.preventDefault(); }} > <div> <button type="submit" className="signUpbutton"> {"Send the message again"} </button> </div> </form> ); }; const CONFIRMATION_CODE = gql`

Cache data may be lost when replacing the my field of a Query object

心不动则不痛 提交于 2021-01-04 07:59:12
问题 this my code const NewVerificationCode = () => { const { loading, error, data = {}, refetch } = useQuery(CONFIRMATION_CODE, { skip: true, onError: (err) => {}, }); console.log(loading, error, data); if (loading || error) { return <ErrorLoadingHandler {...{ loading, error }} />; } return ( <form onSubmit={(e) => { refetch(); e.preventDefault(); }} > <div> <button type="submit" className="signUpbutton"> {"Send the message again"} </button> </div> </form> ); }; const CONFIRMATION_CODE = gql`

How can I make this a callable utils function that contains a hook?

岁酱吖の 提交于 2021-01-04 06:36:09
问题 I'm currently using Apollo Client's useQuery and useMutation hooks to perform the same function in several different components. Instead of repeating the logic, I would like to create a helper function that can keep the logic in a single place. The problem with this, is useQuery and useMutation being hooks mean they can't just live in a separate file as functions, but instead need to be valid React function components. I started trying to make something functional but starting to think this