Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6290

How to define a model with mobx-state-tree with unknow properties

$
0
0

I have to create a model using MobX-State-Tree that represents the response of an API. The response is like this TypeScript type:

type Tree = {  question: string,  field: string,  options: Record<string, Tree>};

If you look close, you will see it uses a TS Record and recursive approach and I couldn't find how to reproduce the options type it in MST. So far I'm stucked with

import { types } from "mobx-state-tree"export const Tree = types  .model("Tree")  .props({    question: types.string,    field: types.string,    options: ???

Viewing all articles
Browse latest Browse all 6290

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>