Skip to content

Reactively rendering component values #317

Answered by linonetwo
sigvik asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, I find miniplex is very similar to Redux, where it is compared by object reference. So you have to refresh the object reference:

    for (const entity of gameContextQuery) {
      ECS.world.remove(entity);
      ECS.world.add({ ...entity, selectedSkillId: skillId, currentState: 'skillTargeting' });
    }

this works, while the following code is wrong:

// this is wrong
    for (const entity of gameContextQuery) {
      ECS.world.removeComponent(entity, 'selectedSkillId');
      ECS.world.removeComponent(entity, 'currentState');
      ECS.world.removeComponent(entity, 'context');
      ECS.world.addComponent(entity, 'context', true);
      ECS.world.addComponent(entity, 'selectedSkillId', 

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@sigvik
Comment options

Answer selected by sigvik
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants