How to deal with the json data obtained in react.

I have obtained a json data and want to merge the same ones together. For example, there are two stores in Pudong New area in the picture, and all the stores are shown under the area name.

clipboard.png
here is my code:

import React,{Component} from "react"
import "./Cinemalist.css"
import {connect} from "react-redux"
import axios from "axios"

class Cinemalist extends Component{

    componentDidMount(){
        this.props.getCinemalist()
    }

    render(){
        return(
            <div id="cinemalist">
                <ul className="cinemalist-ul">
                    {
                        this.props.mylist.map(item=>
                            <li key={item.id}>
                                <p className="title">{item.district.name}

<div className="cinema"> <h4 className="cinema-name">{item.name}</h4> <p className="cinema-add">{item.address}

</div> </li> ) } </ul> </div> ) } } export default connect( (state)=>{ return { mylist:state.cinemalistReducer } },{ getCinemalist:()=>{ return (dispatch)=>{ axios.get("/v4/api/cinema?__t=1529633184561").then(res=>{ console.log(res.data); dispatch({ type:"getcinemaData", payload:res.data.data.cinemas }) }) } } } )(Cinemalist)

data uses deep replication:

var cinemalist = (prevstate=[],data={})=>{
    let {type,payload} = data;

    switch(type){
        case "getcinemaData":
            return [...prevstate,...payload];
        default :
            return prevstate;
    }
    return prevstate;
}

export default cinemalist
Mar.21,2021

can you give me the data structure?


the current data structure is an array, which can be looped, and the item of the same area is stored in an array. The data structure changes from an one-tier array to a two-tier array, and then you can display

on the page.
Menu