Live data from Hacker News

Beyond React 16 by Dan Ambramov – Async Rendering and React Suspense

youtube.com

11–20 of 66 posts

Re: Beyond React 16 by Dan Ambramov – Async Rendering and React Suspense

#11
post #5

Is there plan to implement the react-core in C or other native language ? I can see that being compiled to webassembly for browsers and react-native can have multiple language support ?

I remember a while ago someone shared a SSR C implementation of React.

Re: Beyond React 16 by Dan Ambramov – Async Rendering and React Suspense

#14
post #9
post #4

Earlier quoted context omitted.

Yep, nice link roundup - beat me to it :) Also see the summary post on the React blog for the key takeaways from the demo: https://reactjs.org/blog/2018/03/01/sneak-peek-beyond-react-...

Thanks for the link. But boy, the Apple presentation style is so heavy in that blog post. "We call this...", "We can't wait..."

Sorry if the tone was a bit much! I figured it would be helpful to establish common terminology that people can refer to, and I'm serious about our excitement here – not exaggerating.

Re: Beyond React 16 by Dan Ambramov – Async Rendering and React Suspense

#15
post #12

Maybe a dumb question or wrong forum. But how do you start using latest React in a project?

None of the demoed capabilities are released yet.

The current version of React is 16.2 (see release notes: https://reactjs.org/blog/2017/11/28/react-v16.2.0-fragment-s... ). 16.3 is getting closer to release and will include several new aspects, such as revisions to the lifecycle methods and a simpler `createRef` API. The async stuff that was demoed today is likely to be in a 16.4 release later this year.

Re: Beyond React 16 by Dan Ambramov – Async Rendering and React Suspense

#16
post #3

So glad someone captured this talk! At the 15 minute mark, he introduces a new paradigm for asynchronous IO within render functions; see a screenshot here: https://www.dropbox.com/s/wybqgtftuyqipk8/Screenshot%202018-... . This is groundbreaking, to say the least, as previously this needed to be done by adding higher-order components to inject the result of the fetch as a prop at some higher level; now, it's as simple…

So I am guessing if a prop is `instanceof Promise` or some other constructor then it must trigger this response . . . is that correct?

The key phrase is "thenable", which is a term for anything where `typeof variable.then === "function"` is true.

Re: Beyond React 16 by Dan Ambramov – Async Rendering and React Suspense

#17
post #5

Is there plan to implement the react-core in C or other native language ? I can see that being compiled to webassembly for browsers and react-native can have multiple language support ?

I saw somewhere that someone was working on something similar in Swift, but can't seem to find the link.

Re: Beyond React 16 by Dan Ambramov – Async Rendering and React Suspense

#18

Earlier quoted context omitted.

So I am guessing if a prop is `instanceof Promise` or some other constructor then it must trigger this response . . . is that correct?

The key phrase is "thenable", which is a term for anything where `typeof variable.then === "function"` is true.

But only when passed to HTML elements I hope. Because say I have my own type of the shape `{ then(): Whatever }` and try to pass that as a prop to one of my components I don't want React to invoke that function.

Re: Beyond React 16 by Dan Ambramov – Async Rendering and React Suspense

#19

Earlier quoted context omitted.

The key phrase is "thenable", which is a term for anything where `typeof variable.then === "function"` is true.

But only when passed to HTML elements I hope. Because say I have my own type of the shape `{ then(): Whatever }` and try to pass that as a prop to one of my components I don't want React to invoke that function.

It's not about passing props - the "thenable" detection comes into play if you throw a promise (or something shaped like a promise) from within `render()`.

Re: Beyond React 16 by Dan Ambramov – Async Rendering and React Suspense

#20
post #3

So glad someone captured this talk! At the 15 minute mark, he introduces a new paradigm for asynchronous IO within render functions; see a screenshot here: https://www.dropbox.com/s/wybqgtftuyqipk8/Screenshot%202018-... . This is groundbreaking, to say the least, as previously this needed to be done by adding higher-order components to inject the result of the fetch as a prop at some higher level; now, it's as simple…

So I am guessing if a prop is `instanceof Promise` or some other constructor then it must trigger this response . . . is that correct?

React isn't changing any logic of the types of props; if you actually pass a Promise as a prop, it will be treated 100% as it was in previous React versions.

What's happening instead is that imageFetcher.read() either returns a string OR throws a promise; it never returns a Promise.

So either gets instantiated with the fetched Foo, or throws so React.createElement(Component, ...) never gets called in the first place.

Only if you physically throw a Promise (or "thenable") does the new logic apply: https://github.com/facebook/react/pull/12279/files#diff-1996... is called inside an exception handler.

Post reply on HN