Git Product home page Git Product logo

Comments (4)

alloy avatar alloy commented on June 25, 2024 1

I need to spend more time with Relay, but I wonder what a more client-side complex app will look like and how one would manage "application state" over the data fetching story.

What “state” are you thinking of?

From what I’ve seen, Force has very little client-side state. The bits it has can probably all live in a component’s state dictionary.

I'm also curious how much value we're getting out of Relay when we expect to mainly do server-side rendering—which I expect would typically involve pretty simple fetch().then(() => res.send(ReactComponent)) code. I guess the component portability/static analysis?

Code locality, the data requirements are in the same file as the component that needs it. The components don’t have to deal with actually fetching that data and optimising multiple queries into 1.

Whether this happens on the server or the client makes little difference.

(Currently we serialise the Relay request data so that the client doesn’t need to make any unnecessary requests as well, but it’s not entirely clear how/if that would work in Relay 2.)

The static analysis component applies somewhat right now, but it’s going to play a much bigger role in Relay 2.

from relational-theory.

acjay avatar acjay commented on June 25, 2024

I was going to chime in about React Router. To be fair, it gets mixed reviews from the API churn it has had over the past year or so. But I do think that the impact of those changes is quite overblown, and I also think it's a pretty good choice for being able to share routes between client and server, and it's pretty simple to use. I think of it as a declarative way to select the layout of the page from the route, rather than the more imperative Express flow, which also doesn't map as well to the client, AFAIK. There are probably other good options as well, but I'm not highly familiar.

from relational-theory.

alloy avatar alloy commented on June 25, 2024
  • Not something for now, but opportunity for later—we could probably wrap up a fair bit of boilerplate in modules/framework-ey stuff. For instance, there's a lot of noise here to basically say "render a component on the #root element".
  • These HTML strings are kinda ugly, could we use stateless react components instead?
  • Might go without saying, but config like this should be moved to environment variables and a .env file
  • It might be good to be able to toggle off hot module loading (e.g. with an env var), b/c it can get kinda magical and full of edge cases (ideally we'd avoid having if (module.hot) clutter the code too)

Totally 👍 These are currently all only consequences of getting the tech we want to experiment with up and running as fast as possible.

  • For bigger projects I'd encourage a modular architecture. E.g. what we do in Force/MG where you have sub-apps and a components directories that make it easy to say "fork" the artist page by copying the sub-app and splitting between the two at a routing level. The co-location of files also makes it easy to experiment and drop old code. I also think this provides obvious "escape hatches" for when one finds themselves fighting the React/Relay/etc. stack, e.g. they could implement a sub-app that does more vanilla Express stuff or introduces a new approach to UI suited to that edge case need.

Makes a lot of sense 👍 #20

  • Be careful with doing universal stuff with Webpack, because some of the Webpack loader features can make server-side rendering a pain

Totally, I’m not adding any Webpack stuff that I don’t fully understand or won’t work with our setup.

  • Eventually would be good to include docs on the whole VSCode/tooling setup

Agreed. @orta wanna pick that up?

  • Have we considered any universal routing solutions like React Router (not suggesting it, just curious)?

Thus far my only consideration has been that I don’t want to introduce any of that until there’s a good reason to do so. I would prefer all routing to happen server-side. In my opinion it makes it easier to decide what type of routing to do when, where routing is performed, and just simplifies reasoning about the app in general.

from relational-theory.

craigspaeth avatar craigspaeth commented on June 25, 2024

Yeah generally Force doesn't have a lot of client-side state, but occasionally it will have quite a bit of it (e.g. https://www.artsy.net/collect, inquiry modal flows, other onboarding/set-management style interfaces). I think leaving this to component's internal state is a totally good default and I'm happy to have Relay's co-location + query aggregating benefits 👍 Thanks for explaining!

from relational-theory.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.