When i am trying to get data from rich text box from list and bind it to pnp Rich text box nothing is visible in control, though the data is there in that state i have assigned, i have checked in developer tool.....but it is not showing #588
Labels
import * as React from 'react';
import styles from './RichTextTest.module.scss';
import { IRichTextTestProps } from './IRichTextTestProps';
import { escape } from '@microsoft/sp-lodash-subset';
import { sp } from "@pnp/sp";
import { RichText } from "@pnp/spfx-controls-react/lib/RichText";
import { autobind } from 'office-ui-fabric-react/lib/Utilities';
import "@pnp/sp/webs";
import "@pnp/sp/lists";
import "@pnp/sp/items";
export interface ISpfxPnpRichtextState {
description: string;
SuccessMessage: string;
}
export default class RichTextTest extends React.Component<IRichTextTestProps, ISpfxPnpRichtextState,{}> {
constructor(props: IRichTextTestProps, state: ISpfxPnpRichtextState) {
super(props);
sp.setup({
spfxContext: this.props.context
});
this.state = { SuccessMessage: '', description: '' };
this._getDescription();
}
public render(): React.ReactElement {
return (
< RichText isEditMode={true} value={this.state.description} />
);
}
@autoBind
private async _getDescription() {
const item: any = await sp.web.lists.getByTitle("Employee Registration").items.getById(61).get();
console.log(this.state.description);
console.log(item.Description);
let dummyElement = document.createElement("DIV");
dummyElement.innerHTML = item.Description;
let outputText = dummyElement.innerText;
this.setState({ description: outputText });
}
@autoBind
private async _updateDescription() {
console.log(this.state.description);
const updatedItem = await sp.web.lists.getByTitle("Employee Registration").items.getById(61).update(
{
Description: this.state.description
});
this.setState({ SuccessMessage: 'Successfully saved' });
}
}
The text was updated successfully, but these errors were encountered: