# JavaScript: prodigy.update(...) doesn't trigger a re-render

**URL:** <https://support.prodi.gy/t/javascript-prodigy-update-doesnt-trigger-a-re-render/2264>\
**Category:** Uncategorized\
**Tags:** enhancement\
**Created:** [November 27, 2019, 9:26pm UTC](https://support.prodi.gy/t/javascript-prodigy-update-doesnt-trigger-a-re-render/2264 "2019-11-27T21:26:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbaiter](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/jbaiter/32/533_2.png) [@jbaiter](https://support.prodi.gy/u/jbaiter)\
**Post date:** [November 27, 2019, 9:26pm UTC](https://support.prodi.gy/t/javascript-prodigy-update-doesnt-trigger-a-re-render/2264/1 "2019-11-27T21:26:54Z")

</div>

I'm currently playing around with Prodigy's JavaScript API and ran into a problem when using the `update(...)` function. The documentation says that it will trigger a shallow merge of the current task object. Since the frontend is based on React/Redux and I get back the corresponding `UPDATE_TASK` action object, I was expecting the UI to re-render based on the state update I provided, but this was not the case.

I'm running the latest Prodigy version and am using the `ner_manual` interface, my goal was to play around with other methods for adding the entity spans. Unfortunately not getting visual feedback for the updated span state is kind of a dealbreaker for that 🙂

I'm updating the spans on the current task like this:

```javascript
prodigy.update({
  spans: [
    ...prodigy.content.spans,
    { start: 0, end: 5, token_start: 0, token_end: 0,
       label: 'PER' }
]})

```

This will return the corresponding Redux action (`UPDATE_TASK`) with the correct data, and `prodigy.content` also contains the updated task. However, the UI does not seem to re-render. It also seems that the update corrupted the state, since I can now also no longer add a span on the token targeted by my custom span via the regular interface. If I then add another span via the regular interface, the span I added via `update` disappears again, but I'm still not able to click-select a span to the token targeted by it.

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [November 27, 2019, 9:51pm UTC](https://support.prodi.gy/t/javascript-prodigy-update-doesnt-trigger-a-re-render/2264/2 "2019-11-27T21:51:33Z")

</div>

Good point – this makes sense, because exposing the update method wasn't originally designed for this kind of use case and was mostly supposed to support custom interfaces and adding arbitrary content to the current task object. The manual spans interface keeps separate state of the spans etc. and doesn't only use the current task object as the single source of truth. So just calling `update` doesn't currently work here. It currently needs a different internal method that _then_ delegates to `update`.

I _think_ it should be possible to adjust the interface to make this use case possible, and I also think it shouldn't be a problem for the other interfaces (most of them probably already do support it).

---

<div class="post-metadata">

**Author:** ![jbaiter](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/jbaiter/32/533_2.png) [@jbaiter](https://support.prodi.gy/u/jbaiter)\
**Post date:** [November 28, 2019, 9:07am UTC](https://support.prodi.gy/t/javascript-prodigy-update-doesnt-trigger-a-re-render/2264/3 "2019-11-28T09:07:22Z")

</div>

Thanks for clarifying! It's not really an urgent need for me at the moment, I just noticed it while exploring the API.  
Maybe there should be a note in the documentation about this, though. I'm probably not the only one jumping to conclusions on what `update` does 🙂 Especially since the "uppercase the text" example mutates the task state, which does result in a re-render (probably because this is happening in the `html` view?)
