r/javascript • • Jul 26 '17

React 16 beta

https://github.com/facebook/react/issues/10294
36 Upvotes

26 comments sorted by

11

u/gajus0 Jul 26 '17

A fair warning: I did not manage to get a basic React v16 application to be index by Google. It looks like something in their code-base is breaking the Google crawler. The same issue can be replicated using old Chrome version, e.g. Chrome v24. I've sent a message about it to a member of the React team, but haven't heard back yet.

3

u/brianvaughn Jul 27 '17

Is this something specific to version 16?

If so, do you have a repro?

If so, will you add info as a comment on the issue this post links to?

2

u/gajus0 Jul 27 '17

It is specific to v16. Repro would be a simple ReactDOM.render(<div>Hello, World</div>, [..]) and then just try to render the page using Fetch as Google (see https://medium.com/@gajus/react-application-seen-as-a-blank-page-via-fetch-as-google-afb11dff8562).

As to why I have not created an issue, to quote my original message (07/12/2017):

Didn't post on social media/ public as it would cause unnecessary FUD, esp. if unconfirmed by Google

1

u/Capaj Jul 27 '17

Gajus just curious-did you include the Map/Set polyfills when you tried that?

2

u/gajus0 Jul 27 '17

I was using https://polyfill.io/v2/ when testing this, i.e. yes.

1

u/gaearon Jul 27 '17

Did you try UMD builds or did you bundle the app? Can you provide a full reproducing example please?

1

u/gajus0 Jul 28 '17

I've bundled the app using webpack. I've tried to setup a simple demo, but for some reason this build is failing entirely; some error about usage of "use strict".

https://github.com/gajus/react-webpack-babel-tutorial

Will look into it tomorrow morning.

1

u/gaearon Aug 03 '17

Can you please try again with 16.0.0-beta.3?

We fixed the use strict issue, and the crawler issue might also have been caused by it.

2

u/gajus0 Aug 04 '17

I can confirm that with 16.0.0-beta.3 I was able to render the application using both Chrome v25 and Fetch as Google.

1

u/gajus0 Aug 04 '17 edited Aug 04 '17

I've tried again updating to v16, but I am getting some really weird behaviour https://youtu.be/jsG9_gC5cy4. CC /u/brianvaughn Sorry for a video instead of a replicable test case. I can try to isolate this, but it is no small task.

Whatever is going on here, I am able to replicate it using v15.

1

u/gajus0 Sep 09 '17 edited Sep 09 '17

The issue exists afterall. I have noticed drop in traffic after updating production to React 16.0.0-rc.2. Turns out it is due to new pages not being indexed.

http://imgur.com/a/L4DTc

You can see it live here https://go2cinema.com/.

You will need to use an old browser such as Chrome v25.

That error:

Uncaught TypeError: cannot set property 'nextEffect' of undefined

Is coming from react code base.

The same issue is affecting Fetch as Google.

I am not able to replicate the same issue using "Hello, World" example. I am guessing it might be something to do with setState or context being using in the real world app.

Opened React issue: https://github.com/facebook/react/issues/10656

2

u/imguralbumbot Sep 09 '17

Hi, I'm a bot for linking direct images of albums with only 1 image

https://i.imgur.com/mVKpVUI.jpg

Source | Why? | Creator | ignoreme | deletthis

1

u/gaearon Sep 11 '17

Update: we figured out it's due to a bug in Polyfill.io: https://github.com/Financial-Times/polyfill-service/issues/1299

1

u/brianvaughn Aug 04 '17

Hi /u/gajus0! 16 beta 3 was release this afternoon. We believe it will resolve the Google crawler issue you mentioned. Would you be willing to give it another try?

Details here: https://github.com/facebook/react/issues/10294#issuecomment-320113497

0

u/[deleted] Jul 27 '17

[deleted]

0

u/Woolbrick Jul 27 '17

This is my thought as well. Google's not going to crawl an SPA app that's only generated on the client side, since it doesn't execute JS!

10

u/ECrispy Jul 27 '17

Actually Google indexing bots do execute js but will not do it for complex pages.

8

u/Woolbrick Jul 27 '17

Right, but you have literally no idea what limited sandboxed JS Google will run. You have to design your pages assuming Google's not going to run anything.

3

u/gajus0 Jul 27 '17

My test has been always to see if it works on Chrome v24. If it works, it will work for Google bot. I've got that the precision of syntax errors.

2

u/jacquesdancona Jul 27 '17

Do you have any source for that?

1

u/avenp Jul 27 '17

It also wont render if there is any asynchronous code/ajax calls.

2

u/[deleted] Jul 27 '17

How is performance looking for irl apps?

2

u/[deleted] Jul 27 '17 edited Jul 27 '17

Dan Abramov on Twitter said that Fiber-beta doesn't focus on performance, rather backwards compatibility. There shouldn't be any changes but in one of the next passes (16.x) they will allow you to opt into async rendering, that is the part that will make a difference.

1

u/jacquesdancona Jul 27 '17

Ugh, you're right.

3

u/[deleted] Jul 27 '17

Still, return types, error boundaries, portals and all the other stuff. So much stuff to play with until then. : ]