You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from monkey-patching Relay, I have confirmed that firstReact.default === react is true, which makes me think this is a Webpack issue.
and the ReactRelayContext code after being passed through Webpack looks like this:
varreact=__webpack_require__(3729);varreact_default=/*#__PURE__*/__webpack_require__.n(react);;// CONCATENATED MODULE: ../node_modules/relay-hooks/lib/es/ReactRelayContext.js/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow strict-local * @format */varcreateRelayContext=relay_runtime.__internal.createRelayContext;varReactRelayContext_ReactRelayContext=createRelayContext((react_default()));
which looks like it's passing in React.default rather than the plain React in this invocation. Bizarrely, in the same build react-relay in calling createReactContext without Webpack unwrapping React.
At this point, I must admit that I am not sure if this is a relay-hooks bug, a Webpack bug, or perhaps a Next.js configuration bug. But I did notice that if I monkey-patch node_modules/relay-hooks/lib/es/ReactRelayContext.js and change import React from 'react'; into import * as React from 'react';, the issue does not occur. So perhaps this is a relay-hooks bug?
The text was updated successfully, but these errors were encountered:
hmmm it also seems that if I monkey-patch node_modules/relay-hooks/package.json and remove the module link, i.e. change the module to be CommonJS only, the issue also goes away.
as a workaround, going to try to find a way to prefer the CommonJS version unless I can figure out why Webpack is messing up with the React.default.
Running into a very similar issue as #194, a SSR build of a Next.js 13 project is failing from this call: https://github.com/relay-tools/relay-hooks/blob/master/src/ReactRelayContext.ts#L18
in particular, the
react === firstReact
invariant is failing: https://github.com/facebook/relay/blob/main/packages/relay-runtime/store/createRelayContext.js#L39from monkey-patching Relay, I have confirmed that
firstReact.default === react
istrue
, which makes me think this is a Webpack issue.and the ReactRelayContext code after being passed through Webpack looks like this:
which looks like it's passing in
React.default
rather than the plainReact
in this invocation. Bizarrely, in the same buildreact-relay
in callingcreateReactContext
without Webpack unwrapping React.At this point, I must admit that I am not sure if this is a relay-hooks bug, a Webpack bug, or perhaps a Next.js configuration bug. But I did notice that if I monkey-patch
node_modules/relay-hooks/lib/es/ReactRelayContext.js
and changeimport React from 'react';
intoimport * as React from 'react';
, the issue does not occur. So perhaps this is a relay-hooks bug?The text was updated successfully, but these errors were encountered: