I've created an application with tabs, ok?
And I've created a component that launch a query using apollo client.
My problem is that on first time it's all ok, do the query and get the response, but when I change other tab doesnt launch query again.
How can force that launch query again?
Here is my code:
const GeojsonLayer = ({
layerId,
dynamic = true,
mapId,
map,
performance = true,
deployment = false,
onLoadingLayer,
onErrorLayer,
onLoadedLayer,
}: PerformanceLayerType) => {
const dmas = useSelector(
(state: GlobalReducerStateType) => state?.checkboxtree?.selectedDmas
);
const technologies = useSelector((state: GlobalReducerStateType) => {
state?.app?.technologies?.map(
(technology: TechNologyType) => technology.readingMethodCode
);
});
const { loading, error, data } = useQuery(FEATURE_LAYERS, {
variables: {
dmas,
technologies,
performance,
deployment,
},
});
useEffect(() => {
if (error) {
onErrorLayer(error);
}
}, [error]);
useEffect(() => {
onLoadingLayer(loading);
}, [loading]);
useEffect(() => {
if (!loading && data) {
const layer: GOGeoJsonLayer = map
?.getStaging(mapId)
?.getLayer(layerId);
layer.addFeatures(data, dynamic);
onLoadedLayer(layer);
}
}, [data]);
return null;
};
export default GeojsonLayer;
question from:
https://stackoverflow.com/questions/65891295/how-to-launch-apollo-query 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…