Skip to content
Snippets Groups Projects
Commit 16fde75b authored by chris's avatar chris
Browse files

check mounted

parent af422d78
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ import React, { ...@@ -7,6 +7,7 @@ import React, {
useEffect, useEffect,
forwardRef, forwardRef,
useImperativeHandle, useImperativeHandle,
useState,
} from 'react'; } from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import { EditorState } from 'prosemirror-state'; import { EditorState } from 'prosemirror-state';
...@@ -45,18 +46,18 @@ const WaxView = forwardRef((props, ref) => { ...@@ -45,18 +46,18 @@ const WaxView = forwardRef((props, ref) => {
const context = useContext(WaxContext); const context = useContext(WaxContext);
const { createPortal } = useContext(PortalContext); const { createPortal } = useContext(PortalContext);
const [mounted, setMounted] = useState(false);
context.app.setContext({ ...context, createPortal }); context.app.setContext({ ...context, createPortal });
const schema = context.app.getSchema(); const schema = context.app.getSchema();
const setEditorRef = useCallback( const setEditorRef = useCallback(
node => { node => {
if (node) { if (node) {
context.app.bootServices(); if (!mounted) {
context.app.getShortCuts(); context.app.bootServices();
context.app.getRules(); context.app.getShortCuts();
context.app.getRules();
}
const options = WaxOptions({ const options = WaxOptions({
...props, ...props,
schema, schema,
...@@ -80,6 +81,8 @@ const WaxView = forwardRef((props, ref) => { ...@@ -80,6 +81,8 @@ const WaxView = forwardRef((props, ref) => {
}, },
); );
setMounted(true);
context.updateView( context.updateView(
{ {
main: view, main: view,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment