I have this react code which set the state::
onMoveUp={(ids: SelectedIdMap) => {
this.setState({
xyz: {
...this.state.xyz,
[tt]: [
...this.state.xyz[tt].filter(a => (a.id in ids)),
...this.state.xyz[tt].filter(a => !(a.id in ids)),
],
},
});
}}
This code changes the index of passed array element (ids) to the top of array.
Current state is like this::
{"51f6c052-b218-45ce-b3db-c9b95249e03a":[{"id":"11553dc4-d194-476c-9e05-aaac28ea3e76","prediction":"India–Japan relations","confidence":1},{"id":"3f76ce1d-a821-4418-a332-3285176ae456","prediction":"Japan Democratic Party (1954) politicians","confidence":1},{"id":"031d3913-984a-4af7-aaa3-73e23c206ff1","prediction":"Japan–Taiwan relations","confidence":1}]}
I am unable to understand what [tt] means in this code & how it is updated.
ids = 11553dc4-d194-476c-9e05-aaac28ea3e76 in the parameter.
It is silly question but please help me understand it.
[tt]means "an object key set to the value of the variable namedtt". The code you provided does not show wherettis defined, presumably it's somewhere else in that file