Giter Site home page Giter Site logo

Comments (10)

ericclemmons avatar ericclemmons commented on August 11, 2024 1

@gilesbradshaw Yes, I can work up a solution for you on this.

from react-resolver.

gilesbradshaw avatar gilesbradshaw commented on August 11, 2024

I am a little confused. The server has rendered the markup - having made the asynchronous call. The client then also makes the asynchronous call - after having done it's render. Surely the point is that the call has been made on the server so it doesn't need to be re made by the client? Ie the client should just accept the markup from the server.

from react-resolver.

gilesbradshaw avatar gilesbradshaw commented on August 11, 2024

my project is here btw - wld be grateful if you could have a look!

https://github.com/gilesbradshaw/react-flummox

http://localhost:7000/app2 brings up the warning + does async calls on both server + client

from react-resolver.

iamdustan avatar iamdustan commented on August 11, 2024

@gilesbradshaw we’ve been using this PR for all of our isomorphic projects of late: #34

Basically, you have to tell react-resolver that the call has already been made and put that data into memory (not just into markup).

from react-resolver.

gilesbradshaw avatar gilesbradshaw commented on August 11, 2024

I wish I understood that @iamdustan - could you very kindly explain further?

from react-resolver.

gilesbradshaw avatar gilesbradshaw commented on August 11, 2024

I have made a script on the serer which says

<script async>var __resolver__ = {".0":{"fulfilled":true,"rejected":false,"values":{}},".0.0":{"fulfilled":true,"rejected":false,"values":{"linkName":"APPPPPP","link":"app1","list":[{"id":0,"content":"ahhhh"}]}}};</script><script src="http://localhost:7001/assets/main-33d5ca2650f97c3b76c5.js"></script><script src="http://localhost:7001/assets/0.7bb83fb274f8d7d75a21.hot-update.js"></script>

now I need to rehydrate that on the client not sure how though! :)

from react-resolver.

ericclemmons avatar ericclemmons commented on August 11, 2024

@gilesbradshaw Sorry this isn't public API yet!

You can instantiate a const hydratedResolver = new Resolver(window.__resolver__) on the client;

constructor(states = {}) {
this.frozen = false;
this.promises = [];
this.states = states;
}

And pass it in to Resolver.render via:

Resolver.render(<Handler />, document.getElementById("app"), hydratedResolver);

static render(element, node, instance = new Resolver()) {
React.render((
<Container resolver={instance}>
{element}
</Container>
), node);
return instance;
}

That should work!

from react-resolver.

gilesbradshaw avatar gilesbradshaw commented on August 11, 2024

got it! - actually I just did new Resolver(0 - it defaults to resolver at least in what I have - but passing resolver (or whatever) to Resolver makes sense.

Really pleased about that :)

I assume now resolver can be the whole tree of fetched data from the server. + also hopefully some of the data can not be fetched on the server and would then be fetched by the client.

from react-resolver.

ericclemmons avatar ericclemmons commented on August 11, 2024

@gilesbradshaw Right. When rendering on the server, you should be able to do something like window.__resolver__ = JSON.stringify(resolver.states); to get the history.

Whatever comes back is all that's necessary to recreate the entire tree for initial load, then work as normal thereafter!

from react-resolver.

ericclemmons avatar ericclemmons commented on August 11, 2024

Alright, so this is entirely solved in v2. Closing in favor of that...

from react-resolver.

Related Issues (20)

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.