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

use refs

parent d847b87d
No related branches found
No related tags found
1 merge request!336Fix parsing content
import React, { useLayoutEffect, useState, useMemo } from 'react';
import React, { useLayoutEffect, useState, useMemo, useRef } from 'react';
import { Wax } from 'wax-prosemirror-core';
......@@ -38,11 +38,15 @@ const Editoria = () => {
finalConfig = configMobile;
key = 'editoriaMobile';
}
const editorRef = useRef();
const EditoriaComponent = useMemo(
() => (
<>
<button onClick={() => editorRef.current.getContent()}>Click</button>
<Wax
ref={editorRef}
key={key}
config={finalConfig}
autoFocus
......
/* eslint react/prop-types: 0 */
import React, { useEffect, useState } from 'react';
import React, {
useEffect,
useState,
forwardRef,
useRef,
useImperativeHandle,
} from 'react';
import { each } from 'lodash';
import { DOMSerializer } from 'prosemirror-model';
......@@ -23,7 +29,7 @@ const createApplication = props => {
return application;
};
const Wax = props => {
const Wax = forwardRef((props, ref) => {
const [application, setApplication] = useState();
useEffect(() => {
......@@ -32,6 +38,12 @@ const Wax = props => {
return () => newApplication.resetApp();
}, []);
useImperativeHandle(ref, () => ({
getContent() {
console.log('content');
},
}));
const {
autoFocus,
browserSpellCheck,
......@@ -114,7 +126,7 @@ const Wax = props => {
</PortalProvider>
</WaxProvider>
);
};
});
Wax.defaultProps = {
config: { services: [] },
......
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