Minor renaming

This commit is contained in:
Rainer Simon 2021-07-10 09:24:54 +02:00
parent b29bb21d34
commit 724fc68e00
1 changed files with 5 additions and 4 deletions

View File

@ -1,17 +1,18 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
export default class WrappedWidget extends Component { export default class WrappedWidget extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.element = React.createRef(); this.element = React.createRef();
} }
updateWidget(props) { renderWidget(props) {
const widgetEl = this.props.widget({ const widgetEl = this.props.widget({
annotation: props.annotation, annotation: props.annotation,
readOnly: props.readOnly, readOnly: props.readOnly,
...this.props.config, ...props.config,
onAppendBody: body => props.onAppendBody(body), onAppendBody: body => props.onAppendBody(body),
onUpdateBody: (previous, updated) => props.onUpdateBody(previous, updated), onUpdateBody: (previous, updated) => props.onUpdateBody(previous, updated),
onRemoveBody: body => props.onRemoveBody(body), onRemoveBody: body => props.onRemoveBody(body),
@ -26,13 +27,13 @@ export default class WrappedWidget extends Component {
} }
componentDidMount() { componentDidMount() {
this.updateWidget(this.props); this.renderWidget(this.props);
} }
componentWillReceiveProps(next) { componentWillReceiveProps(next) {
if (this.element.current) { if (this.element.current) {
if (this.props.annotation !== next.annotation) { if (this.props.annotation !== next.annotation) {
this.updateWidget(next); this.renderWidget(next);
} }
} }
} }