/*
 * A component to safely render non-empty noscript elements.
 *
 * See https://github.com/facebook/react/issues/1252.
 */

import React, {Component} from 'react';
import {renderToStaticMarkup} from 'react-dom/server';

export default class NoScript extends Component {

    render() {
        const contents = renderToStaticMarkup(this.props.children);
        return <noscript
            dangerouslySetInnerHTML={{__html: contents}}
        />;
    }

}

/*
 * A component to safely render non-empty noscript elements.
 *
 * See https://github.com/facebook/react/issues/1252.
 */

import PropTypes from 'prop-types';
import React, {Component} from 'react';
import {renderToStaticMarkup} from 'react-dom/server';

export default class NoScript extends Component {

    static contextTypes = {
        router: PropTypes.object,
    }

    render() {
        const contents = renderToStaticMarkup(
            // Since we're triggering an entirely separate render here,
            // we need to manually restart the threading of the router
            // context. Otherwise, `<Link to="/">` elements will render
            // without hrefs.
            <RouterContextProvider router={this.context.router}>
                {this.props.children}
            </RouterContextProvider>
        );
        return <noscript
            dangerouslySetInnerHTML={{__html: contents}}
        />;
    }

}


class RouterContextProvider extends Component {

    static childContextTypes = {
        router: PropTypes.object,
    }

    getChildContext() {
        return {router: this.props.router};
    }

    render() {
        return this.props.children;
    }

}

Fix in-app links inside noscript contexts
Fix in-app links inside noscript contexts

Summary:
These were rendering without `href`, which made them unclickable. See
comments in this patch for explanation of the root cause and fix.

Test Plan:
Visit `/skills` in a text-based browser like `lynx` or a graphical
browser with JavaScript disabled. Note that in-app links, like those
under the “Java” section, are now clickable and resolve correctly.
