React.Children.only error occurs when a React component expects a single child element but receives multiple or invalid elements. This can happen when passing arrays directly as children or making incorrect conditional renderings. To fix this, always map arrays to React elements and wrap them in a container. Ensure to wrap multiple elements in one and check the conditional rendering syntax. Common components that use Children.only internally include Modals, Portals, Tooltips, Context providers, and Animation wrappers.
Table of contents
Permalink The error explainedPermalink Common mistake: Forgetting to map arraysPermalink How to fix array issuesPermalink Other common causesPermalink Components that often cause this errorPermalink Quick fixes checklistSort: