Answer the question
In order to leave comments, you need to log in
How to properly deal with output order in React?
Hello. Please tell me how to solve the following problem. The backend comes with an array of data with the type of widgets, for example:
{
"widgets": [
{
"type": "One",
"data": {
"title": "title1",
"subTitle": "subTitle1",
"thirdText": "thirdText1"
}
},
{
"type": "Three",
"data": {
"title": "title3",
"subTitle": "subTitle3",
"thirdText": "thirdText3"
}
},
{
"type": "Two",
"data": {
"title": "title2",
"subTitle": "subTitle2",
"thirdText": "thirdText2"
}
}
]
}
<React.Fragment>
<ComponentOne />
<ComponentThree />
<ComponentTwo />
</React.Fragment>
<React.Fragment>
<ComponentThree />
<ComponentTwo />
</React.Fragment>
Answer the question
In order to leave comments, you need to log in
Just use widgets.map() - the array is already sorted and will be processed in order.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question