How SEO Works on the ReactJS Page

I use a simple controller to change the ReactJS display view as follows:

    getInitialState: function() {
        return {view: null};
    },
    setViewFromHash: function () {
        var that = this;
        var address = window.location.hash;
        if(address != "")
        {
            address = address.substring(1);
            require(["jsx!" + address], function (View) {
                that.setState({view: View});
            });
        }
        else
        {
            require(["jsx!Home"], function (View) {
                that.setState({view: View});
            });            
        }
    },
    componentWillMount: function () {
        var that = this;
        window.onhashchange = function () {
            that.setViewFromHash();
        };
        this.setViewFromHash();
    },
    onTitleUpdate: function(title, canonical) {
        document.title = title + titleDefault;
        $('link[rel=canonical]').prop('href', canonicalDefault + canonical);
    },
    render: function () {
        var viewToLoad = null;
        if (this.state.view === null) {
            viewToLoad = "Loading...";
        } else {
            viewToLoad = this.state.view({ onTitleUpdate: this.onTitleUpdate });
        }

        return (
            <article>
                {viewToLoad}
            </article>
        );
    }

In the view, I call the callback:

var Home = React.createClass({
    render: function () {
        this.props.onTitleUpdate("Home", "");
...

My question is whether this callback occurs at a point that will benefit SEO, i.e. page title and canonical changes, are they updated to make the Google bot understand that the name and canonical changes?

I am also considering using Cortex to manage my data, would it be better? Worse? No difference? How does the SEO / Google bot perceive the “page” it is viewing?

+4
source share
1

Google , JavaScript ; 2010 :

" JavaScript, . Google JavaScript - JavaScript. , JavaScript, JavaScript. , , JavaScript-, Google Analytics, , phantom Googlebot Google Analytics".

, Google (, , ) JavaScript, , , , . , , , Google , , .

React , . (, , .)

+4

Source: https://habr.com/ru/post/1536192/


All Articles