# Renderers disappear on Interaction Event

**URL:** https://discourse.vtk.org/t/renderers-disappear-on-interaction-event/7887
**Category:** Web
**Created:** [February 22, 2022, 9:09am UTC](https://discourse.vtk.org/t/renderers-disappear-on-interaction-event/7887 "2022-02-22T09:09:21Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![stoune](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/eb8c5e/32.png) [@stoune](https://discourse.vtk.org/u/stoune)
#### Post date: [February 22, 2022, 9:09am UTC](https://discourse.vtk.org/t/renderers-disappear-on-interaction-event/7887/1 "2022-02-22T09:09:21Z")

</div>

Hello, I’m using in React, `ResliceCursorWidget` to get the locations in the brain slices on each `onEndInteractionEvent` and , at the same move a sphere (the red sphere) in other rendrer that display the vtk 3D of the brain, that sphere moves `onInteractionEvent` using :

```auto
             v.widgetInstance.onInteractionEvent(()=> {
              sphere3D.setCenter(widget.getWidgetState().getCenter(););
              grw.getRenderWindow().render(); });

```

The code to get the locations that I display in the page:

```auto
          const [locations, setLocations] = useState([]);
          v.widgetInstance.onEndInteractionEvent(()=> {
            const center = widget.getWidgetState().getCenter();
            const origin = widget.getWidgetState().getImage().getOrigin();
            const locations = [origin[0] - center[0], origin[1] - center[1], origin[2] - center[2]];
            setLocations(locations);// this is the variable that I'm displaying in the page (X: Y: Z: )
          });

```

 ![image](https://discourse.vtk.org/uploads/default/original/2X/0/0186a1937ebe6add6125720c96fb11fc99cda9e6.jpeg)  
The problem is after a few Reslice movements (5-6), all the renderes are disappeared and I get the error below,

PS: when I delete `onEndInteractionEvent` the problem is gone, when I move the code of the `onEndInteractionEvent` in `onInteractionEvent` the problem happens even more rapidly (after 2-3 manipulations)

I don’t understand what is the problem I really need help

![image](https://discourse.vtk.org/uploads/default/original/2X/7/71ac6bfcd3cda473bfe0b44bff00433669d0c9cd.png)

---

<div class="post-metadata">

### Author: ![finetjul](https://discourse.vtk.org/user_avatar/discourse.vtk.org/finetjul/32/154_2.png) [@finetjul](https://discourse.vtk.org/u/finetjul)
#### Post date: [February 23, 2022, 3:33pm UTC](https://discourse.vtk.org/t/renderers-disappear-on-interaction-event/7887/2 "2022-02-23T15:33:25Z")

</div>

It seems that the problems comes from `setLocations()`.  
What if you replace its current content with `console.log()`?

---

<div class="post-metadata">

### Author: ![dexter](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/dc4da7/32.png) [@dexter](https://discourse.vtk.org/u/dexter)
#### Post date: [February 23, 2022, 10:38pm UTC](https://discourse.vtk.org/t/renderers-disappear-on-interaction-event/7887/3 "2022-02-23T22:38:41Z")

</div>

If I replace it with `console.log()` or `React.useRef()` it works fine, I used` React.useRef()` to solve my problem
