Questions tagged [react-fragment]
The react-fragment tag has no usage guidance.
react-fragment
27
questions
1
vote
1
answer
30
views
How to just add the content of a component to Vue DOM and not the wrapper itself, like React.Fragment in React JS
I'm trying to refactor my code into readable and short pieces. Therefore sometimes I need to create a dumb component which only is holding the repetitive part of my code. For example I wanted to use ...
0
votes
3
answers
944
views
MUI: The Menu component doesn't accept a Fragment as a child
Created a Menu component with 3 menu items that are conditionally rendered
It keeps on showing 'MUI: The Menu component doesn't accept a Fragment as a child.
Consider providing an array instead. '. on ...
2
votes
2
answers
2k
views
How to modify react/jsx-no-useless-fragment rule to allow <>{children}</>
I am all for getting rid of useless React Fragments <><Element /></> from my codebase and the ESLint rule react/jsx-no-useless-fragment is great for catching this.
However, there are ...
0
votes
2
answers
276
views
Is a React.Fragment the same as a DocumentFragment?
React.Fragment looks like DocumentFragment. But does React.Fragment has the same performance benefits like DocumentFragment?
In other words, are this
// index.jsx
const arr = [...Array.from({length: ...
1
vote
1
answer
602
views
How to forward input ref to a function by onClick button
I am trying to forward input ref text/string data to a function by clicking the button. but I cant forward or pass the data to my function by using button
--questionRef is my ref input data
--...
1
vote
0
answers
81
views
Vscode <></> changes color of tags to red and can't use any snippets / auto tag / auto import
When I use VS Code and add <></> tag in my code, rest of the code turns red and I can't use an auto tag / snippets / auto import etc...
Does anybody experience this before? How can I fix ...
1
vote
2
answers
283
views
Everything after the react fragment comes in the same color in VS Code (React Fragment)
As the arrow shows .. everything after the closed fragment comes in the same weird color, at the beginning I thought it might be a theme issue but then I recognized that it is not. I really need a ...
2
votes
0
answers
550
views
Check if child renders top-level React Fragment
Is there a way to programmatically check if a React Element returns a top-level React.Fragment component? For most use cases, react-is is the recommended way to check this type of behavior, but it ...
0
votes
2
answers
70
views
Code duplication: how to avoid in Reactjs
Expectation: if the flag is true, then empty div "container" around div "content"
const Demo = () => {
const [flagABC] = useFlagFeature(true)
return (
<div ...
0
votes
1
answer
413
views
React Error: Target container is not a DOM Element: got when loading a Modal Form
I'm working on a shopping cart application using ReactJS and Context-API, so far, I achieved this:
load my products from Firebase
Add product to the cart
The next step is to display the cart's ...
0
votes
0
answers
93
views
Why my browser give me a syntax error about a div?
Browser give me this error What I'm doing wrong? This appeared only when I added the code for the loader
function App(){
const [loading, setLoading] = useState(false);
...
0
votes
1
answer
95
views
When use Syntactical form in react fragment then the editor text color will be changed. How to solve this problem
Here give the problem screenshot. How to solve this problem. have any away for solve this problem
[1]: https://i.sstatic.net/aHUvg.png reactFragment
-3
votes
1
answer
895
views
Can a fragment have an attribute?
I have to set an attribute to the fragment. I want to do something like this:
<className="name">
abcd
</>
Is there any way to do like this?
3
votes
3
answers
795
views
What does a ReactFragment from "react" mean?
I was looking through a .tsx code that looked something like below.
import React, { Fragment, ReactFragment } from "react";
// ...
export interface PageProps {
children: ReactFragment;
...
0
votes
1
answer
118
views
Trying to add loop in function of React JS getting JSX expressions must have one parent element
I tried adding <> </> as mentioned in other answers but that dint work.
Its a simple function component with return statement:
export default function Merchant4SubscriptionForm(props) {
//...