facebook / facebook/relay

[react-relay] Add ability to pass data into react-relay HOC without warning

Open
#2,291 10 comments 3 reactions 0 assignees View on GitHub
wontfix
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

We're currently in the process of incrementally migrating a codebase over to Relay and ran into an issue that we were able to solve on our end, but was wondering if there is any interest in taking a PR at the `react-relay` level to solve officially.

#### Background
At Artsy we have [a repo](https://github.com/artsy/reaction) that we use for sharing React components across various apps. In it we make heavy use of Relay but due to a few issues in one of our consuming codebases we can't yet take advantage. That said, we would still like to make use of these Relay-wrapped components as dumb view components, circumventing the Relay data layer.

#### Solution
To get around this, we are piggybacking on `react-relay`'s use of `context` and are stubbing out our own. (See [this gist](https://gist.github.com/damassi/8bbcc8179a0a4d2513e254737420c1e1) for an implementation example.)

```javascript
render () {
const artwork = { name: 'Banksy' }

return (



)
}
```
So far this works great. Complex trees of data can be rendered all the way down through the main `QueryRenderer` and into individual fragments. However, in development, this produces a warning each time:

screen shot 2018-01-17 at 7 59 04 pm

Would it make sense to account for this at the Relay level and perhaps export an adaptor component similar to the above that users can take advantage of? that in turn would silence this warning? In terms of opening up Relay components to be consumed by _any_ kind of app, this could also provide a good pattern for stubbing out test environments.

Any thoughts on approach would be appreciated. Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.