Javascript ReactJs Type error
I am trying to do "OTHERPAGE" when user clicks back button ... snippet:
onClickBack:function(e){
var parentId = getParentIdById(this.props.id);
React.render(<OTHERPAGE id={parentId} />, document.getElementById('main'));
},
the function runs as I expect. getParentIdById returns UUID as string, just how I need it. calling React.render throws an exception:
message: "element.type is not a constructor"
I don't get it ... I needed React at the top of the page:
var React = require('react');
Does anyone know what the problem might be here?
thanks for the help
EDIT:
I also get this warning: "Warning: Only functions or strings can be set as React components."
Doesn't really help me ...
+3
source to share
1 answer
You need to export the OTHERPAGE file from it:
file OTHERPAGE.react.js:
var OTHERPAGE = React.createClass({...});
module.exports = OTHERPAGE;
use the OTHERPAGE component:
var OTHERPAGE = require('./components/OTHERPAGE.react');
var React = require('react');
var parentId = ...;
React.render(<OTHERPAGE id={parentId} />, document.getElementById('main'));
+5
source to share