зеркало из https://github.com/microsoft/SandDance.git
Renderer setState fix (#675)
* only call setstate after mounted * version patch
This commit is contained in:
Родитель
0f9cfa4321
Коммит
610d506f8e
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@msrvida/sanddance-explorer",
|
||||
"version": "4.1.4",
|
||||
"version": "4.1.5",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@msrvida/sanddance-explorer",
|
||||
"version": "4.1.4",
|
||||
"version": "4.1.5",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"d3-format": "^1.3.2"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@msrvida/sanddance-explorer",
|
||||
"version": "4.1.4",
|
||||
"version": "4.1.5",
|
||||
"description": "SandDance data exploration React component.",
|
||||
"main": "dist/es6/index.js",
|
||||
"repository": {
|
||||
|
|
|
@ -29,6 +29,7 @@ export interface State {
|
|||
function _Renderer(_props: Props) {
|
||||
|
||||
class __Renderer extends base.react.Component<Props, State> {
|
||||
private mounted: boolean;
|
||||
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
|
@ -36,13 +37,21 @@ function _Renderer(_props: Props) {
|
|||
if (!this.state.viewer?.presenter?.morphchartsref) {
|
||||
const t = setInterval(() => {
|
||||
const newState = this.getInitialState(props);
|
||||
if (newState.viewer?.presenter?.morphchartsref) {
|
||||
if (this.mounted && newState.viewer?.presenter?.morphchartsref) {
|
||||
clearInterval(t);
|
||||
this.setState(newState);
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.mounted = true;
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.mounted = false;
|
||||
}
|
||||
|
||||
getInitialState(props: Props): State {
|
||||
const { viewer } = props.explorer;
|
||||
|
|
Загрузка…
Ссылка в новой задаче