Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion packages/web/src/components/basic/ComponentWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class ComponentWrapper extends React.Component {
({ registeredComponentsTimestamps } = this.context.getState());
}
// Unregister components
if (registeredComponentsTimestamps[componentId] === this.$timestamp) {
if (registeredComponentsTimestamps[componentId] === this._timestamp) {
this.props.removeComponent(componentId);
if (this.internalComponent) {
this.props.removeComponent(this.internalComponent);
Expand All @@ -130,8 +130,25 @@ class ComponentWrapper extends React.Component {
}

componentDidMount() {
let components = [];
if (this.context && this.context.getState) {
({ components } = this.context.getState());
}

// Re-register if component was destroyed or not present (e.g. under StrictMode double-mounting)
if (this.props.destroyOnUnmount || components.indexOf(this.props.componentId) === -1) {
this.props.addComponent(this.props.componentId, this._timestamp);
this.props.setQueryListener(this.props.componentId, this.props.onQueryChange, this.props.onError);
this.props.setComponentProps(this.props.componentId, this.props);
}

// Register internal component
if (this.internalComponent) {
if (this.props.destroyOnUnmount || components.indexOf(this.internalComponent) === -1) {
this.props.addComponent(this.internalComponent, this._timestamp);
this.props.setComponentProps(this.internalComponent, this.props);
}

if (this.props.mode !== 'test') {
if (this.props.setReact) {
// Watch component after rendering the component to avoid the un-necessary calls
Expand Down
23 changes: 22 additions & 1 deletion packages/web/src/components/range/DynamicRangeSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,27 @@ class DynamicRangeSlider extends Component {
}

componentDidMount() {
const { mode } = this.props;
const { components, addComponent, setQueryListener, setComponentProps, mode } = this.props;
const currentComponents = components || [];
if (currentComponents.indexOf(this.props.componentId) === -1) {
addComponent(this.props.componentId, this._timestamp);
addComponent(this.internalHistogramComponent, this._timestamp);
addComponent(this.internalRangeComponent, this._timestamp);
setQueryListener(this.props.componentId, this.props.onQueryChange, null);

setComponentProps(this.props.componentId, this.props, componentTypes.dynamicRangeSlider);
setComponentProps(
this.internalHistogramComponent,
this.props,
componentTypes.dynamicRangeSlider,
);
setComponentProps(
this.internalRangeComponent,
this.props,
componentTypes.dynamicRangeSlider,
);
}

if (mode !== 'test') {
this.setReact(this.props);
}
Expand Down Expand Up @@ -800,6 +820,7 @@ const mapStateToProps = (state, props) => {
}
}
return {
components: state.components,
options,
isLoading: state.isLoading[props.componentId],
range,
Expand Down