Skip to content
This repository has been archived by the owner on Jul 19, 2019. It is now read-only.

Warnings #16

Open
daslicht opened this issue Oct 31, 2015 · 1 comment
Open

Warnings #16

daslicht opened this issue Oct 31, 2015 · 1 comment

Comments

@daslicht
Copy link

When I run the example I get the following warnings:

Warning: React.render is deprecated. Please use ReactDOM.render from require('react-dom') instead.warning @ react.js:18769
react.js:18769 Warning: render(): Target node has markup rendered by React, but there are unrelated nodes as well. This is most commonly caused by white-space inserted around server-rendered markup.warning @ react.js:18769
react.js:18769 Warning: Each child in an array or iterator should have a unique "key" prop. Check the top-level render call using <tr>. See https://fb.me/react-warning-keys for more information.warning @ react.js:18769
react.js:18769 Warning: Each child in an array or iterator should have a unique "key" prop. Check the top-level render call using <tbody>. See https://fb.me/react-warning-keys for more information.warning @ react.js:18769

How to fix ?

@Finetuned
Copy link

You can add react-dom into the code as follows:
Caveat: this will not fix ReactDOMServer.renderToString in getMarkup()

Add react-dom.js to the parameters in example.php:

$rjs = new ReactJS(
file_get_contents('../../react/build/react.js'), // location of React's code
    file_get_contents('../../react/build/react-dom.js'), // location of React's code
    file_get_contents('../../react/build/table.js') // app code
);

Amend the constructor in ReactJS.php as follows:

 function __construct($libsrc, $libsrcDom, $appsrc)
    {
        $react = array();
        // stubs, react
        $react[] = "var console = {warn: function(){}, error: print}";
        $react[] = "var global = global || this, self = self || this, window = window || this";
        $react[] = $libsrc;
        $react[] = $libsrcDom;
        $react[] = "var React = global.React";
        $react[] = "var ReactDOM = global.ReactDOM";
        // app's components
        $react[] = $appsrc;
        $react[] = ';';

Replace React with ReactDOM in getJS()

 "ReactDOM.render(React.createElement(%s, %s), %s);",

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants