Is there a way to access a map-like object directly instead of by .get
and .set
#1810
Unanswered
NE-SmallTown
asked this question in
Q&A
Replies: 1 comment
-
As for passing it down to uncontrolled external library - you could pass |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a structure like:
If I define the types like:
when
get
I have to access the instance by
store.usersBySchool.get(school)
, but sometimes I need to pass the instance to a 3-rd party library like<Lib data = { store.usersBySchool } name={ school } />
, in that library, it will access the field byprops.data[props.name]
, so it will throw an error and the tough thing is that I cant modify the 3-rd party library.when
set
I have to set the instance by
const users = store.usersBySchool.get(school); const user = users['xx']; users.set('xxx', { name: 'newName', ...user })
.If it could be
store.usersBySchool.get(school)['xx'].name = 'newName'
, that would more easier and convenient.Expected
So, I want to ask that is there any way to define a key-value object, like the key of the object must be a string, and the value shape of that key must be something like
usersBySchool
, I notice thattypes.refinement
maybe can do this but cant figure it out. Thanks!Beta Was this translation helpful? Give feedback.
All reactions