question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React.Fragment not allowed as returned renderProp

See original GitHub issue

Problem 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
danseethalercommented, Jan 10, 2018

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 😃

0reactions
eriklharpercommented, Jul 5, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found