React.Fragment not allowed as returned renderProp
See original GitHub issueProblem description:
The current setup doesn’t support returning React.Fragment
from the renderProp function. Instead it will reach this line which throws an error.
Suggested solution:
From what I can tell the isDOMElement
function in the utils.js file should be updated to return true if the element is a React fragment. The function is currently returning typeof element.type === 'string'
but in the case of a fragment the element type appears to be a symbol.
I’m happy to create a PR but wanted to have some discussion around it first.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top Results From Across the Web
React.Fragment not allowed as returned renderProp #305
The current setup doesn't support returning React.Fragment from the renderProp function. Instead it will reach this line which throws an error.
Read more >Fragments - React
A common pattern in React is for a component to return multiple elements. Fragments let you group a list of children without adding...
Read more >React Fragment not rendering in function [duplicate]
You have to return the array that is returned from map from getResults . getResults() { let { tracks } = this.state; let...
Read more >Extract Reusable React Components with an As Prop, Render ...
React.Fragment , an as component prop, a renderItem render prop, JSX spread attributes, and object default values are tools you can use to...
Read more >Composing React Components with TypeScript - Pluralsight
The React typings package will allow you to import types from the ... 16 17class King extends Pawn { 18 render() { 19...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the response Kent!
I tried the code here and it looks like it’s throwing a different error
Uncaught TypeError: _this4._rootNode.contains is not a function at onMouseUp (downshift.esm.js:778)
.I’m working on a component that is joined with other components to create a search bar so I was hoping to use a fragment - but at the end of the day you’re right, a div will probably work just fine 😃
A good reason to support fragments in general is when say using a composite component that you build with downshift, whose contents that you ultimately want to render to the DOM need to be direct flex children from a parent DOM node that applies
display: "flex"
. When you include an extraneous root div, it breaks intended flex behavior because the nodes that you want to render inside a fragment are now wrapped inside another element, which instead becomes the flex child.