ericclemmons / react-resolver

Async rendering & data-fetching for universal React applications.
https://ericclemmons.github.io/react-resolver
Other
1.65k stars 52 forks source link

V2 Rewrite #52

Closed ericclemmons closed 9 years ago

ericclemmons commented 9 years ago

Because of bugs with the latest version of React & the upcoming changes to context, this rewrite aims to solve complex server-side rendering first, and then update for client-side usage.

Latest Status

ericclemmons commented 9 years ago

This will be done by this week. An internal project (super complex) relies on it, and the only thing remaining is finish the client-side portion (since state changes require removing pre-loaded data).

ericclemmons commented 9 years ago

React Router Demo

v2-gif

v2-home v2-stargazers

Now onto a Redux demo...

iamdustan commented 9 years ago

:clap: looking nice, @ericclemmons!

ericclemmons commented 9 years ago

What's insanely frustrating is how I just created a React v0.13 exmaple and context.router is lost for anything using <Link /> (despite <RouteHandler /> correctly trying to render the handler).

https://github.com/ericclemmons/react-resolver/tree/34855966f46cc647ae8eb44b82dd1d626a63edec/examples/react-v0.13

$ npm install
$ npm run watch

Visit http://localhost:8080/index.html and click Submit.

Freakin' bizarre mayne.

ericclemmons commented 9 years ago

Just confirmed that in Stargazers.js (when I return early with <p>Howdy!</p> instead of the actual stargazers HTML):

// NO decorators
export default class Stargazers extends React.Component {

// no errors

@resolve("user", ({ params }) => params.user)
export default class Stargazers extends React.Component {

// no errors

@resolve("users", function({ user = "ericclemmons", repo = "react-resolver" }) {
  const url = `https://api.github.com/repos/${user}/${repo}/stargazers`;

  return axios.get(url).then(({ data }) => data);
})
export default class Stargazers extends React.Component {

// no errors

@resolve("user", ({ params }) => params.user)
@resolve("repo", ({ params }) => params.repo)
export default class Stargazers extends React.Component {

Warning: owner-based and parent-based contexts differ (values: undefined vs [object Object]) for key (resolver) while mounting Resolver (see: http://fb.me/react-context-by-parent)

And with all 3 @resolves:

Warning: owner-based and parent-based contexts differ (values: undefined vs [object Object]) for key (resolver) while mounting Resolver (see: http://fb.me/react-context-by-parent) Warning: owner-based and parent-based contexts differ (values: undefined vs [object Object]) for key (resolver) while mounting Resolver (see: http://fb.me/react-context-by-parent)

Already, it's clear that with React v0.13 that nested resolves lose some context despite still working for some reason.

ericclemmons commented 9 years ago

MOTHER F'ING DUPLICATE REACTS!!!!!

ericclemmons commented 9 years ago

React v0.13 example is complete!

https://github.com/ericclemmons/react-resolver/tree/v2/examples/react-v0.13