mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-04 09:28:11 +08:00
protect against reference detach (#1634)
This commit is contained in:
@@ -59,6 +59,11 @@ class Scatterplot extends React.PureComponent {
|
|||||||
/*
|
/*
|
||||||
Must be created for each canvas
|
Must be created for each canvas
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// regl will create a top-level, full-screen canvas if we pass it a null.
|
||||||
|
// canvas should never be null, so protect against that.
|
||||||
|
if (!canvas) return {};
|
||||||
|
|
||||||
// setup canvas, webgl draw function and camera
|
// setup canvas, webgl draw function and camera
|
||||||
const regl = _regl(canvas);
|
const regl = _regl(canvas);
|
||||||
const drawPoints = _drawPoints(regl);
|
const drawPoints = _drawPoints(regl);
|
||||||
@@ -175,9 +180,12 @@ class Scatterplot extends React.PureComponent {
|
|||||||
|
|
||||||
setReglCanvas = (canvas) => {
|
setReglCanvas = (canvas) => {
|
||||||
this.reglCanvas = canvas;
|
this.reglCanvas = canvas;
|
||||||
this.setState({
|
if (canvas) {
|
||||||
...Scatterplot.createReglState(canvas),
|
// no need to update this state if we are detaching.
|
||||||
});
|
this.setState({
|
||||||
|
...Scatterplot.createReglState(canvas),
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
getViewportDimensions = () => {
|
getViewportDimensions = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user