Skip to main content

useHistory or Redirect did not render component with apollo client

Problem: call mutation from MlsForm, and redirect back to Signing page, but did not rerender todos and done docs in Signing page


Solution is use fetchPolicy: 'no-cache'


if (listingId === '') return
const result = await client.query({
query: GET_LISTING_DOCUMENTS,
variables: { listingId: listingId },
fetchPolicy: 'no-cache',
})

const {
data: { getListingDocuments },
} = result

const todos = await client.query({
query: GET_TODO_DOCUMENTS,
variables: { listingId: listingId },
fetchPolicy: 'no-cache',
})

const {
data: { getTodoDocuments },
} = todos


================================


const printPdf = async (form: PrintPdfInput) => {
printListingDocumentToPdf({
variables: {
printPdfInput: form,
},
})
.then((data: any) => {
const linkToSigning = `${url.substr(0, url.search(/mlsform?/))}signing`
history.push(linkToSigning)
})
.catch((error: any) => {
setMessage(error.message)
})
}

 

Comments

Popular posts from this blog

A component is changing an uncontrolled input of type text to be controlled error in ReactJS - Formik

 https://stackoverflow.com/questions/47012169/a-component-is-changing-an-uncontrolled-input-of-type-text-to-be-controlled-erro default value can't be undefined  case 'listingBrokerOfficeName' : value = ( listingBroker || {}). officeName break change to: case 'listingBrokerOfficeName' : value = ( listingBroker || {}). officeName || '' break

apollo client v3 - clean up non-needed packages

v3: https://github.com/apollographql/apollo-client clean up: ApolloProvider useQuery, useMutation, useApolloClient Apollo Client >= 3 includes React hooks functionality out of the box. You don't need to install any additional packages. https://www.apollographql.com/docs/react/api/react/hooks/ //import { ApolloProvider } from '@apollo/react-hooks' import { ApolloProvider } from '@apollo/client/react' //import { useQuery, useMutation, useApolloClient } from '@apollo/react-hooks' import { useQuery, useMutation, useApolloClient } from '@apollo/client' How i can CATCH any error (network and graphql), and prevent promise.reject()  https://github.com/apollographql/apollo-client/issues/6469 npm uninstall @apollo/react-hooks https://github.com/apollographql/apollo-link npm uninstall apollo-link npm uninstall apollo-client npm uninstall apollo-link-error npm uninstall apollo-link-http npm uninstall apollo-link-ws npm uninstall apollo-cache-inmemory

add new site to Vagrant Homestead

Homestead.yaml: folders : - map : ~/ freshinup to : / home / vagrant / code sites : - map : smartmotors . local . com to : / home / vagrant / code / smartmotors / public php : "7.3" - map : arbor . test to : / home / vagrant / code / arbor / public php : "7.3" /etc/hosts: 192.168.10.10 arbor.test 192.168.10.10 smartmotors.local.com vagrant up --provision php artisan smartmotors:seed --quickstart