Answer the question
In order to leave comments, you need to log in
Why React element creation doesn't work?
Hello! One strange feature is of interest. Here is a code example:
There is a React-Router object in which a dynamic route is formed:
{
path: '<какой-то путь>',
getComponent(location, cb) {
require.ensure([], require => {
cb(null, test());
}, '<какой-то чанк-нейм>');
}
}
function PropsPasser(element, props) {
class WrapClass extends React.Component {
constructor(props){
super(props);
}
render(){
//return <element /> <------- ТАК НЕ РАБОТАЕТ (пустая страница)! ПОЧЕМУ?
return React.createElement(element)
}
}
return WrapClass
}
function test(type) {
let asyncObj = require('<какой-то путь>');
let asyncRoute = asyncObj.default;
let propsPasser = PropsPasser(asyncRoute, {type: "pew-pew"});
return propsPasser;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question