Answer the question
In order to leave comments, you need to log in
Higher order components way to return props.children from render?
Decided to write a small library.
I wrote a component that takes one child, forwards data to it in props and must return this child:
let props = this.props;
let child = Children.only(props.children);
return cloneElement(child, Object.assign({}, props, {data: "Данные"}));
render() {
let El = this.renderChildren(this.props);
return (
<El />
);
}
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of `MyComponent`.
Answer the question
In order to leave comments, you need to log in
return (
<El />
)
render() {
return this.renderChildren(this.props);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question