Is there a utility built into SPFx or a React library to change what to render based on if the page is in read or edit mode?
Or more exactly, a way to switch the rendering when switching between read and edit mode.
I am trying to display an edit version of an SPFx Extension when the Site page is in Edit mode. I would like to display other information when the page is in Read mode.
I can get everything to render correctly on initial page load, but toggling between read/edit after that doesn't change anything.
The closest I've gotten is by using History and having my component re-render on URL change using:
history.listen(() => this.forceUpdate());
I tried this in conjunction with react-url-query, but it doesn't seem that
history.listen() is firing when going back-and-forth between read/edit modes even though the URL is updating.
I am NOT currently using either Redux or react-router. I'm not sure if using those would help get me what I'm looking for or if this is more of a SharePoint issue.
The modern pages are built with React, is there a way I can use the same state to tell what mode the page is in?