Merge branch 'react-list-form' of https://github.com/sharepointknight/sp-dev-fx-webparts into pr/1501

This commit is contained in:
Hugo Bernier 2020-09-23 23:37:11 -04:00
commit d2e09e3eac
3 changed files with 11 additions and 12 deletions

View File

@ -35,26 +35,25 @@ export default class ReactAccordion extends React.Component<IReactAccordionProps
}
private getListItems(): void {
if (typeof this.props.listId !== "undefined" && this.props.listId.length > 0) {
sp.web.lists.getById(this.props.listId).items.select("Title", "Content").get()
if(typeof this.props.listId !== "undefined" && this.props.listId.length > 0) {
sp.web.lists.getById(this.props.listId).items.select("Title","Content").get()
.then((results: Array<any>) => {
this.setState({
items: results
});
})
.catch((error: any) => {
.catch((error:any) => {
console.log("Failed to get list items!");
console.log(error);
});
}
}
public componentDidUpdate(prevProps: IReactAccordionProps): void {
if (prevProps.listId !== this.props.listId) {
public componentDidUpdate(prevProps:IReactAccordionProps): void {
if(prevProps.listId !== this.props.listId) {
this.getListItems();
}
if(prevProps.allowMultipleExpanded !== this.props.allowMultipleExpanded || prevProps.allowZeroExpanded !== this.props.allowZeroExpanded) {
this.setState({
allowMultipleExpanded: this.props.allowMultipleExpanded,
@ -67,7 +66,7 @@ export default class ReactAccordion extends React.Component<IReactAccordionProps
const listSelected:boolean = typeof this.props.listId !== "undefined" && this.props.listId.length > 0;
const { allowMultipleExpanded, allowZeroExpanded } = this.state;
return (
<div className={styles.reactAccordion}>
<div className={ styles.reactAccordion }>
{!listSelected &&
<Placeholder
iconName='MusicInCollectionFill'
@ -92,7 +91,7 @@ export default class ReactAccordion extends React.Component<IReactAccordionProps
</AccordionItemButton>
</AccordionItemHeading>
<AccordionItemPanel>
<p dangerouslySetInnerHTML={{ __html: item.Content }} />
<p dangerouslySetInnerHTML={{__html: item.Content}} />
</AccordionItemPanel>
</AccordionItem>
);