deck.gl seProps circular definition

Hi, I’m running into a circular definition RuntimeError when I try to do the following in deck.gl. I’m trying to defind a new DeckGL instance and have a onViewStateChange function update a property of this instance

deckgl = {

  var zoomMode = 'X'
  
  return new deck.DeckGL({
    container,
    views: new deck.OrthographicView(),
    controller: {scrollZoom: true, inertia: true, zoomAxis: 'X'},
    initialViewState: {target: [0, 0, 0], zoom: [0, 0]},

    // circular definition
    onViewStateChange: ({viewState}) => {
      
      const nextZoomMode = viewState.zoom[0] > 3 ? 'all' : 'X'
      if (zoomMode !== nextZoomMode) {

        // update zoom mode
        zoomMode = nextZoomMode

        console.log(zoomMode)

        // update Props
        deckgl.setProps({
          controller: {zoomAxis: zoomMode}
        })    
        
      }
    }
    
  });
}

Here is a link to the notebook with the error and a Github page describing more background on the notebook.

Any help would be greatly appreciated :slight_smile:

Access the instance by assigning it to a local variable:

const instance = new deck.DeckGL({
// ...
   instance.setProps({

or via the context (presumably, didn’t verify it’s the right context):

   this.setProps({
1 Like

Thanks @mootari !! The first approach worked see - deck.gl Tutorial: Custom Primitive Layer - 2D Zoom Test, fix circular / Nicolas Fernandez | Observable