I was building a Reactjs component, that should toggle between two child components.
<Toggle> <Comp1> <Comp2> </Toggle> The render method of Toggle looked like this render() { const content = React.Children.count(this.props.children) > 0 ? this.props.children[0] : this.props.children[1]; return ( ${content} ); }
Unfortunately, this didn’t work (index out of bounds), when I passed only one component instead of two. This doesn’t make sense since the Toggle is supposed to toggle between two components.
I help people create remarkable things. Focus on the customer and quality. Opinions are my own. Photography is my other passion.