Ich habe Immutable wie dieseImmutable JS: Sollwert der Karte innerhalb Karte
Immutable.Map({
name: action.data.name,
avatarUrl: action.data.up,
profileUrl: action.data.upl,
id: action.data.uid,
role: Immutable.fromJS(action.data.r),
color: Immutable.Map({
initial: '#00FF00',
})
});
Alles, was ich möchte zu überprüfen, ob ein Wert zu einem Schlüssel entsprechenden Innen color map
vorhanden ist, dann ändern Sie es. Wenn es nicht existiert, einen neuen Schlüssel innerhalb color map
mit dem neuen Wert wie folgt hinzu:
Immutable.Map({
name: action.data.name,
avatarUrl: action.data.up,
profileUrl: action.data.upl,
id: action.data.uid,
role: Immutable.fromJS(action.data.r),
color: Immutable.Map({
initial: '#00FF00',
c-0: '#000000',
7: '#0000FF'
})
});
Was ich versucht das ist, aber es aint arbeiten und fügt Schlüssel überall.
return state.setIn(state.getIn('color', action.thread_id), action.code);
thread_id ist der Schlüssel, wie 'C-0' oder '7' und Code enthält den Wert gegen den Schlüssel
Update 1 Beim Hinzufügen von Tasten wie ‚c- hinzugefügt oder aktualisiert werden, 0' und 'c-1' und '7' und '8', fügt er im Innern der Karte wie
Immutable.Map({
name: action.data.name,
avatarUrl: action.data.up,
profileUrl: action.data.upl,
id: action.data.uid,
role: Immutable.fromJS(action.data.r),
c: Immutable.Map({
-: Immutable.Map({
0: '#00F0F0',
1: '#0000F0',
})
})
7: '#FFFF00',
8: '#00FFFF',
color: Immutable.Map({
initial: '#00FF00'
})
});
Mit 'state.getIn ([ 'colo r ',' initial ']) ', ich kann nicht auf den Wert des Schlüsselanfangs zugreifen. Jede Hilfe wäre zu erwarten – iamsaksham