Skip to content

Commit 8cb73db

Browse files
alunyovfacebook-github-bot
authored andcommitted
Fix configuration issue with the HookImplementation injector
Reviewed By: yungsters Differential Revision: D53316835 fbshipit-source-id: 4753b275c896d191b65e037438a313f23272536e
1 parent 65c8acd commit 8cb73db

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/react-relay/relay-hooks/HooksImplementation.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import type {UseRefetchableFragmentType} from './legacy/useRefetchableFragment';
1616
import typeof useFragment from './useFragment';
1717
import type {UsePaginationFragmentType} from './usePaginationFragment';
1818

19+
import warning from 'warning';
20+
1921
type HooksImplementation = {
2022
useFragment: useFragment,
2123
usePaginationFragment: UsePaginationFragmentType,
@@ -24,12 +26,21 @@ type HooksImplementation = {
2426
};
2527

2628
let implementation: HooksImplementation | null = null;
29+
let alreadyRequested = false;
2730

2831
function inject(impl: HooksImplementation): void {
32+
if (alreadyRequested) {
33+
warning(
34+
false,
35+
'HooksImplementation were requested before they were injected.',
36+
);
37+
return;
38+
}
2939
implementation = impl;
3040
}
3141

3242
function get(): HooksImplementation | null {
43+
alreadyRequested = true;
3344
return implementation;
3445
}
3546

0 commit comments

Comments
 (0)