Skip to content
This repository was archived by the owner on Nov 23, 2021. It is now read-only.

Commit de51f19

Browse files
catamphetaminejamiebuilds
authored andcommitted
React 16: A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.
Explains how to workaround `A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.` error.
1 parent f090130 commit de51f19

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,13 @@ For example, you cannot pass children types aren't valid pre React 16:
8787
</Context.Provider>
8888
```
8989

90+
It will throw `A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.` because `<Context.Provider>` can only receive a single child element. To fix the error just wrap everyting in a single `<div>`:
9091

92+
```js
93+
<Context.Provider>
94+
<div>
95+
<div/>
96+
<div/>
97+
</div>
98+
</Context.Provider>
99+
```

0 commit comments

Comments
 (0)