Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[react-native] Avoid using ExecutionEnvironment.canUseDOM #2954

Closed
morrys opened this issue Nov 28, 2019 · 4 comments
Closed

[react-native] Avoid using ExecutionEnvironment.canUseDOM #2954

morrys opened this issue Nov 28, 2019 · 4 comments

Comments

@morrys
Copy link
Contributor

morrys commented Nov 28, 2019

The canUseDOM variable defined with the following condition: !!(typeof window !== 'undefined' && window.document && window.document.createElement);
This condition returns false in react-native context.

The change only affects relay-experimental & tests:

@josephsavona
Copy link
Contributor

What is the issue here?

@morrys
Copy link
Contributor Author

morrys commented Dec 4, 2019

Hi @josephsavona,
I try to explain myself better:

As specified in the comment below, this condition must be true when “executed in a server environment”.
https://github.com/facebook/relay/blob/master/packages/relay-experimental/QueryResource.js#L153-L157

// NOTE: If we're executing in a server environment, there's no need
// to create temporary retains, since the component will never commit.
if (!ExecutionEnvironment.canUseDOM) {
return {dispose: () => {}};
}

While it is true even when it is executed in a react-native environment because ExecutionEnvironment.canUseDOM is false both on the server side and in react-native.

So even in react-native does not do the temporaryRetain.

@jstejada
Copy link
Contributor

I think this makes sense, will test internally and land

facebook-github-bot pushed a commit that referenced this issue Dec 19, 2019
Summary:
This PR resolves the issue #2954 and fixes jest.mock.
Pull Request resolved: #2960

Reviewed By: kassens

Differential Revision: D19071027

Pulled By: jstejada

fbshipit-source-id: 3d5e216b23f5fe170ec75856d3bea484a77c1d37
jstejada pushed a commit that referenced this issue Dec 19, 2019
Summary:
This PR resolves the issue #2954 and fixes jest.mock.
Pull Request resolved: #2960

Reviewed By: kassens

Differential Revision: D19071027

Pulled By: jstejada

fbshipit-source-id: 3d5e216b23f5fe170ec75856d3bea484a77c1d37
@morrys
Copy link
Contributor Author

morrys commented Dec 20, 2019

This issue can be closed as it is resolved in this PR #2960.

@morrys morrys closed this as completed Dec 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants