I am trying to render "OTHERPAGE" when a user clicks the back button ... snippet:
onClickBack:function(e){
var parentId = getParentIdById(this.props.id);
React.render(<OTHERPAGE id={parentId} />, document.getElementById('main'));
},
the function triggers as i expect it. getParentIdById returns the UUID as a string, just how I need it. calling React.render throws an exception:
message:"element.type is not a constructor"
I dont get it... I required React on top of the page:
var React = require('react');
does anyone know what the problem could be here?
Thanks for helping
EDIT:
I also get this warning:
"Warning: Only functions or strings can be mounted as React ponents."
Doesn't really help me though...
I am trying to render "OTHERPAGE" when a user clicks the back button ... snippet:
onClickBack:function(e){
var parentId = getParentIdById(this.props.id);
React.render(<OTHERPAGE id={parentId} />, document.getElementById('main'));
},
the function triggers as i expect it. getParentIdById returns the UUID as a string, just how I need it. calling React.render throws an exception:
message:"element.type is not a constructor"
I dont get it... I required React on top of the page:
var React = require('react');
does anyone know what the problem could be here?
Thanks for helping
EDIT:
I also get this warning:
"Warning: Only functions or strings can be mounted as React ponents."
Doesn't really help me though...
Share Improve this question edited Jul 6, 2018 at 7:46 Aliaksandr Sushkevich 12.5k8 gold badges41 silver badges46 bronze badges asked Nov 29, 2014 at 21:37 Max BumayeMax Bumaye 1,00710 silver badges18 bronze badges 6-
2
My guess is
OTHERPAGE
isn't what you think it is. What's the output ofconsole.log(OTHERPAGE)
? – Michelle Tilley Commented Nov 29, 2014 at 22:38 - I think you are right... it returned "Object { }" instead of "function OTHERPAGE(config, children)" ... but why? – Max Bumaye Commented Nov 29, 2014 at 22:42
- Max, that's outside the scope of the information you've given. – Brigand Commented Nov 29, 2014 at 23:17
- Yes @FakeRainBrigand I fear it is. I was hoping that it was some kind of mon issue... I am trying to restructure using react-router – Max Bumaye Commented Nov 30, 2014 at 0:05
- Did you ever resolve this issue? I'm having the exact same error. – Lee Commented Jan 6, 2015 at 15:57
1 Answer
Reset to default 6You have to export the OTHERPAGE from it's file:
file OTHERPAGE.react.js:
var OTHERPAGE = React.createClass({...});
module.exports = OTHERPAGE;
use the OTHERPAGE ponent:
var OTHERPAGE = require('./ponents/OTHERPAGE.react');
var React = require('react');
var parentId = ...;
React.render(<OTHERPAGE id={parentId} />, document.getElementById('main'));
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744288502a4566917.html
评论列表(0条)