So, I'm having this specific error :
Uncaught Error: Objects are not valid as a React child (found: object with keys {name, component, accessible, is_showed, is_rendered}). If you meant to render a collection of children, use an array instead or wrap the object using createFragment(object) from the React add-ons. Check the render method of
Base.
I have a Redux state that looks like the following :
export const initialState = {
links: [{
name: 'search_files',
component: <SearchFile/>,
accessible: true,
is_showed: true,
is_rendered: false
},
{
name: 'invisible_link',
component: <SearchFile/>,
accessible: false,
is_showed: true,
is_rendered: false
}
],
user: {
username: '',
password: '',
is_logged: false,
has_rights: false,
errors: {
summary: '',
username: '',
password: ''
}
},
panel: {toggled: false}
};
My intent is to render the component pointed by the component property of each link. For the moment, the component is the same for the two links, it's "normal".
The Base component looks like this :
class Base extends React.Component {
render() {
let toRender = null;
if (!this.props.state.user.is_logged)
toRender = <LoginFormRender/>;
else
{
toRender = this.props.state.links.find(link => {
if (link.is_rendered) {
console.log(link.component);
return (link.component);
}
})
}
return (
<div>
<TopBarApp/>
<LeftPanel/>
{toRender}
</div>
)
}
}
export default Base;
The LoginFormRender is rendering just good, but the error is here :
else
{
toRender = this.props.state.links.find(link => {
if (link.is_rendered) {
console.log(link.component);
return (link.component); <==== HERE
}
})
}
I understand that I visibly can't do it like this (but still, it works storing a component in a var, as LoginFormRender works) but I can't figure out how to achieve this ... Does somebody knows ? I couldn't find any question on SO that answers my question..
Thanks in advance