Skip to content

Commit

Permalink
preload/loadQuery should invariant if used during render
Browse files Browse the repository at this point in the history
Reviewed By: tyao1

Differential Revision: D19163471

fbshipit-source-id: 4cfb798e8733e9783068f1cbe8f0ba91e2bad1aa
  • Loading branch information
Juan Tejada authored and facebook-github-bot committed Dec 19, 2019
1 parent 06d17de commit ff3bd43
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/relay-experimental/loadQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

const React = require('react');

const invariant = require('invariant');
const preloadQuery_DEPRECATED = require('./preloadQuery_DEPRECATED');
const warning = require('warning');

import type {
PreloadableConcreteRequest,
Expand Down Expand Up @@ -55,7 +55,7 @@ function loadQuery<TQuery: OperationType, TEnvironmentProviderOptions>(
// $FlowFixMe
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
?.ReactCurrentDispatcher?.current;
warning(
invariant(
RenderDispatcher == null || CurrentDispatcher !== RenderDispatcher,
'Relay: `preloadQuery` (or `prepareEntryPoint`) should not be called inside a React render function.',
);
Expand Down

0 comments on commit ff3bd43

Please sign in to comment.