Define a mobx type for an unkown key?

  javascript, mobx, mobx-react, mobx-state-tree, reactjs

Currently have a data set with an object of arrays where each array has it’s unique id as a key for reference.

 "relations": {
            "19271934": [
                19271894
            ],
            "19621318": [
                19621538,
                19621586
            ],
            "19788661": [
                19788191
            ],
            "19788662": [
                19788192
            ]
        }
    }

Would like to create a model for an individual relation so it would be something like this.

 relations: types.Map(types.model({
          relationId: types.optional(types.array(RelationModel),[]) 
     })),

where the relationId would be the unique id I have no way for knowing before.

Source: Ask Javascript Questions

LEAVE A COMMENT