admin管理员组文章数量:1401835
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'));
本文标签: Javascript ReactJs Type errorStack Overflow
版权声明:本文标题:Javascript ReactJs Type error - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744288502a2598999.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论