Fix React Error on setState while rendering a different component
This commit is contained in:
parent
b3a3be0ba2
commit
f5ec81d22b
2 changed files with 26 additions and 16 deletions
|
@ -1,4 +1,4 @@
|
|||
import React, { Dispatch, SetStateAction, useEffect, useRef, useState } from 'react';
|
||||
import React, { Dispatch, SetStateAction, useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { events as EVENTS } from '../../Events/AppEvents';
|
||||
import { MainMenu } from '../MainMenu/MainMenu';
|
||||
import { ContainerModel, IContainerModel } from '../../Interfaces/IContainerModel';
|
||||
|
@ -107,6 +107,10 @@ export function App(props: IAppProps): JSX.Element {
|
|||
|
||||
UseHTTPGETStatePreloading(isLoaded, setEditorState, setLoaded);
|
||||
|
||||
const enableLoaded = useCallback(() => {
|
||||
setLoaded(true);
|
||||
}, []);
|
||||
|
||||
if (isLoaded) {
|
||||
return (
|
||||
<div
|
||||
|
@ -130,7 +134,9 @@ export function App(props: IAppProps): JSX.Element {
|
|||
>
|
||||
<MainMenu
|
||||
newEditor={() => NewEditor(
|
||||
editorState, setEditorState, setLoaded
|
||||
editorState,
|
||||
(newEditor) => setEditorState(newEditor),
|
||||
enableLoaded
|
||||
)}
|
||||
loadEditor={(files: FileList | null) => LoadEditor(
|
||||
files,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue