Update to rerender on item change

Refreshes the webpart when an item is changed within the properties panel
This commit is contained in:
Omar 2021-07-29 10:22:37 +01:00
parent 94a7f97ab5
commit e43321bcc2
1 changed files with 9 additions and 0 deletions

View File

@ -68,6 +68,15 @@ export default class HeroWebpart extends React.Component<IHeroWebpartProps, IHer
return b;
}
public componentDidUpdate(prevProps : IHeroWebpartProps, prevState : IHeroState) : void
{
// If properties have changed bind it and update webpart
if(this.props.items !== prevProps.items || this.state.items !== prevState.items)
{
this.setState({items:this.props.items})
}
}
public render(): React.ReactElement<IHeroWebpartProps> {
if(this.state.items.length<=0){
this._getItems();