Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// has unmounted
if (isMountedRef.current !== true) {
warning(
false,
'Relay: Unexpected call to `refetch` on unmounted component for fragment ' +
'`%s` in `%s`. It looks like some instances of your component are ' +
'still trying to fetch data but they already unmounted. ' +
'Please make sure you clear all timers, intervals, ' +
'async calls, etc that may trigger a fetch.',
fragmentNode.name,
componentDisplayName,
);
return {dispose: () => {}};
}
if (
Scheduler.unstable_getCurrentPriorityLevel() <
Scheduler.unstable_NormalPriority
) {
warning(
false,
'Relay: Unexpected call to `refetch` at a priority higher than ' +
'expected on fragment `%s` in `%s`. It looks like you tried to ' +
'call `refetch` under a high priority update, but updates that ' +
'can cause the component to suspend should be scheduled at ' +
'normal priority. Make sure you are calling `refetch` inside ' +
'`startTransition()` from the `useSuspenseTransition()` hook.',
fragmentNode.name,
componentDisplayName,
);
}
if (parentFragmentRef == null) {
warning(
(...callArgs) => {
if (
Scheduler.unstable_getCurrentPriorityLevel() <
Scheduler.unstable_NormalPriority
) {
warning(
false,
'Relay: Unexpected call to `%s` at a priority higher than ' +
'expected on fragment `%s` in `%s`. It looks like you tried to ' +
'call `refetch` under a high priority update, but updates that ' +
'can cause the component to suspend should be scheduled at ' +
'normal priority. Make sure you are calling `refetch` inside ' +
'`startTransition()` from the `useSuspenseTransition()` hook.',
args.direction === 'forward' ? 'loadNext' : 'loadPrevious',
args.fragmentNode.name,
args.componentDisplayName,
);
}
export function queueExplicitHydrationTarget(target: Node): void {
if (enableSelectiveHydration) {
let priority = getCurrentPriorityLevel();
const queuedTarget: QueuedHydrationTarget = {
blockedOn: null,
target: target,
priority: priority,
};
let i = 0;
for (; i < queuedExplicitHydrationTargets.length; i++) {
if (priority <= queuedExplicitHydrationTargets[i].priority) {
break;
}
}
queuedExplicitHydrationTargets.splice(i, 0, queuedTarget);
if (i === 0) {
attemptExplicitHydrationTarget(queuedTarget);
}
}