Skip to content

Refreshing View on React State Change #2691

Answered by garrettjstevens
davegcodes asked this question in Q&A
Discussion options

You must be logged in to vote

You should be able to get the track to update dynamically, but it'll have to be approached in a bit different way. The adapter in a track gets read once when JBrowse starts and populates its internal state, but then isn't used after that. That's why changing the adapter like that doesn't work, since it's already been read.

You can, however, update the internal state that gets created. Here's an example function that should add a feature to a FromConfigAdapter:

function addFeature(newFeature) {
  const currentFeatures = [
    ...viewState?.config.tracks[0].adapter.features.value,
  ]
  currentFeatures.push(newFeature)
  viewState?.config.tracks[0].adapter.features.set(currentFeatures)
}

In…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@davegcodes
Comment options

@davegcodes
Comment options

@garrettjstevens
Comment options

Answer selected by davegcodes
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