1

I have a need for a Mobx observable object which simply returns whichever property is asked of it as a string. For example, myObs.description would simply return the string "description". With a normal JS object, I would use a proxy with a custom getter, like so:

    new Proxy({}, {
      get: (obj, prop) => {
        return prop.toString();
    }})

I can't do this with Mobx as the API uses a Proxy object that I can't update. Is there a way to use Mobx to create an observable object that can have a custom computed value for any and every property passed to it?

Nathan
  • 185
  • 1
  • 2
  • 10
  • Can you make some minimal example on https://codesandbox.io? So far it's not clear what you want. – Danila May 04 '22 at 18:14

0 Answers0