In react, I have component(anchor component) which we are getting response from an api as array of objects. From payload I’m requesting 6 objects.I want to arrange 3 in one side and another 3 beside that. Now I’m getting all in 1 side. How to arrange this. Can someone please help?
Not able to proceed with anything specific
2
Answers
To arrange the 6 objects from your API response into two rows of 3 objects each, you can use React’s component rendering to create the desired layout. Here’s a step-by-step guide on how to achieve this:
Assuming you have an array of objects named apiResponse
I wrote a small example that might help you:
Here’s how it should look in the end:
In the above example, I supposed that
values
is the response array you receive based on your API call.Also, please take into account that you might want to move that inline style (I used it to speed-up the implementation and to easily show the CSS I applied).