How to conditionally render a node view

I have a mediaWithCaption node which consists of two nodes media (required) and caption (optional). Here is the view (react):

	return (
		<NodeViewWrapper
			as="div"
			className={
				"media-with-caption-node-view " +
				(isFloat
					? "f-" + node.attrs.dataFloat
					: isAlign
					? "justify-" + node.attrs.dataAlign
					: "")
			}
		>
			<figure>
				<NodeViewContent></NodeViewContent>
			</figure>
		</NodeViewWrapper>
	);
}

I want to add a command which toggles the caption view. What is the correct way to do this? My first though was to add a caption attribute to mediaWithCaption and depending on the value of this attribute, render caption view or not, but I don’t know how to split <NodeViewContent></NodeViewContent> into captionView component and mediaView component. Any ideas?