Skip to content

Commit

Permalink
Rename useIsParentQueryInFlight to useIsParentQueryActive
Browse files Browse the repository at this point in the history
Reviewed By: kassens

Differential Revision: D19965115

fbshipit-source-id: 4619b38ff9a4a71396fbac2201690189450c2abd
  • Loading branch information
Juan Tejada authored and facebook-github-bot committed Feb 19, 2020
1 parent 251701d commit 3794f0b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const RelayEnvironmentProvider = require('../RelayEnvironmentProvider');
// $FlowFixMe
const TestRenderer = require('react-test-renderer');

const useIsParentQueryInFlight = require('../useIsParentQueryInFlight');
const useIsParentQueryActive = require('../useIsParentQueryActive');

const {
Environment,
Expand Down Expand Up @@ -84,7 +84,7 @@ beforeEach(() => {
it('returns false when owner is not pending', () => {
let pending = null;
function Component() {
pending = useIsParentQueryInFlight(fragment, fragmentRef);
pending = useIsParentQueryActive(fragment, fragmentRef);
return null;
}
TestRenderer.create(
Expand All @@ -105,7 +105,7 @@ it('returns false when an unrelated owner is pending', () => {
expect(fetch).toBeCalledTimes(1);
let pending = null;
function Component() {
pending = useIsParentQueryInFlight(fragment, fragmentRef);
pending = useIsParentQueryActive(fragment, fragmentRef);
return null;
}
TestRenderer.create(
Expand All @@ -121,7 +121,7 @@ it('returns true when owner is started but has not returned payloads', () => {
expect(fetch).toBeCalledTimes(1);
let pending = null;
function Component() {
pending = useIsParentQueryInFlight(fragment, fragmentRef);
pending = useIsParentQueryActive(fragment, fragmentRef);
return null;
}
TestRenderer.create(
Expand All @@ -148,7 +148,7 @@ it('returns true when owner fetch has returned payloads but not completed', () =
});
let pending = null;
function Component() {
pending = useIsParentQueryInFlight(fragment, fragmentRef);
pending = useIsParentQueryActive(fragment, fragmentRef);
return null;
}
TestRenderer.create(
Expand Down Expand Up @@ -176,7 +176,7 @@ it('returns false when owner fetch completed', () => {
});
let pending = null;
function Component() {
pending = useIsParentQueryInFlight(fragment, fragmentRef);
pending = useIsParentQueryActive(fragment, fragmentRef);
return null;
}
TestRenderer.create(
Expand Down Expand Up @@ -205,7 +205,7 @@ it('returns false when owner fetch errored', () => {
dataSource.error(new Error('wtf'));
let pending = null;
function Component() {
pending = useIsParentQueryInFlight(fragment, fragmentRef);
pending = useIsParentQueryActive(fragment, fragmentRef);
return null;
}
TestRenderer.create(
Expand All @@ -220,7 +220,7 @@ it('returns false when owner fetch errored', () => {
it('does not update the component when the owner is fetched', () => {
const states = [];
function Component() {
states.push(useIsParentQueryInFlight(fragment, fragmentRef));
states.push(useIsParentQueryActive(fragment, fragmentRef));
return null;
}
TestRenderer.create(
Expand All @@ -243,7 +243,7 @@ it('does not update the component when a pending owner fetch returns a payload',
expect(fetch).toBeCalledTimes(1);
const states = [];
function Component() {
states.push(useIsParentQueryInFlight(fragment, fragmentRef));
states.push(useIsParentQueryActive(fragment, fragmentRef));
return null;
}
TestRenderer.create(
Expand Down Expand Up @@ -275,7 +275,7 @@ it('updates the component when a pending owner fetch completes', () => {
expect(fetch).toBeCalledTimes(1);
const states = [];
function Component() {
states.push(useIsParentQueryInFlight(fragment, fragmentRef));
states.push(useIsParentQueryActive(fragment, fragmentRef));
return null;
}
TestRenderer.create(
Expand All @@ -302,7 +302,7 @@ it('updates the component when a pending owner fetch errors', () => {
expect(fetch).toBeCalledTimes(1);
const states = [];
function Component() {
states.push(useIsParentQueryInFlight(fragment, fragmentRef));
states.push(useIsParentQueryActive(fragment, fragmentRef));
return null;
}
TestRenderer.create(
Expand All @@ -327,7 +327,7 @@ it('updates the component when a pending owner fetch with multiple payloads comp
expect(fetch).toBeCalledTimes(1);
const states = [];
function Component() {
states.push(useIsParentQueryInFlight(fragment, fragmentRef));
states.push(useIsParentQueryActive(fragment, fragmentRef));
return null;
}

Expand Down Expand Up @@ -380,7 +380,7 @@ it('should only update if the latest owner completes the query', () => {
function Component() {
const [ref, setRefFn] = React.useState(fragmentRef);
setRef = setRefFn;
const pending = useIsParentQueryInFlight(fragment, ref);
const pending = useIsParentQueryActive(fragment, ref);
return <Renderer pending={pending} />;
}
TestRenderer.create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ const {getFragment} = require('relay-runtime');

import type {GraphQLTaggedNode} from 'relay-runtime';

function useIsParentQueryInFlight<TKey: ?{+$data?: mixed, ...}>(
function useIsParentQueryActive<TKey: ?{+$data?: mixed, ...}>(
fragmentInput: GraphQLTaggedNode,
fragmentRef: TKey,
): boolean {
const fragmentNode = getFragment(fragmentInput);
useStaticFragmentNodeWarning(
fragmentNode,
'first argument of useIsParentQueryInFlight()',
'first argument of useIsParentQueryActive()',
);
return useIsOperationNodeActive(fragmentNode, fragmentRef);
}

module.exports = useIsParentQueryInFlight;
module.exports = useIsParentQueryActive;

0 comments on commit 3794f0b

Please sign in to comment.