1

I'm busy with this course and almost to the end. One of the challenges at the end stated to add code to do the CRUD operations on the content of the page. So I have this code from the course:

function CreatePageForm( { onCancel, onSaveFinished } ) { const [title, setTitle] = useState(); const { lastError, isSaving } = useSelect( ( select ) => ( { lastError: select( coreDataStore ) .getLastEntitySaveError( 'postType', 'page' ), isSaving: select( coreDataStore ) .isSavingEntityRecord( 'postType', 'page' ), } ), [] ); const { saveEntityRecord } = useDispatch( coreDataStore ); const handleSave = async () => { const savedRecord = await saveEntityRecord( 'postType', 'page', { title, status: 'publish' } ); if ( savedRecord ) { onSaveFinished(); } }; return ( <PageForm title={ title } onChangeTitle={ setTitle } hasEdits={ !!title } onSave={ handleSave } lastError={ lastError } onCancel={ onCancel } isSaving={ isSaving } /> ); } 

Can I now add something like this:

[content, setContent] = useState() 

and work from there on further?

1
  • Depends on what you expect that to be. Did you attempt it? Commented Oct 13 at 14:44

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.