Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React TypeError: React.renderComponent is not a function

Tags:

reactjs

render

I've got this weird message after following a React tutorial building a simple app. http://blog.revathskumar.com/2014/05/getting-started-with-react.html

I used bower to install react and included the scripts like so:

<script src="bower_components/react/react.js"></script>
<script src="bower_components/react/JSXTransformer.js"></script>

as in the tutorial. At first I thought the scripts weren't loaded but that's obviously not the case. What is the problem?

like image 885
Webconstructor Avatar asked Jun 07 '15 21:06

Webconstructor


3 Answers

These days it is

ReactDOM.render(

and include the source file:

<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.0/react-dom.js"></script>

This is the warning from React:

Warning: React.render is deprecated. Please use ReactDOM.render from require('react-dom') instead.
like image 156
Connor Leech Avatar answered Nov 13 '22 11:11

Connor Leech


bower installs the latest version in this case version 0.12.0.

there is a change in the render function convention.

https://facebook.github.io/react/blog/2014/10/28/react-v0.12.html

Component has been removed from all of our React.render* methods.

so use

    React.render(

instead of

   React.renderComponent(
like image 17
Webconstructor Avatar answered Nov 13 '22 10:11

Webconstructor


Lately 'React.render()' is depreciated So use 'ReactDom.render()'

import React from 'react';
import ReactDom from 'react-dom';
import App from './components/App.jsx';
require('./main.scss');

ReactDOM.render(<App />, document.getElementById('container'));
like image 7
Ignatius Andrew Avatar answered Nov 13 '22 12:11

Ignatius Andrew