Draft-js-plugins: TypeError: Cannot read property 'offsetTop' of undefined

Created on 19 Aug 2020  路  3Comments  路  Source: draft-js-plugins/draft-js-plugins

Hi all, i have the next bug, Using next js

nextjs

and here is my code

`import React from 'react';
import Layout from '../components/Layout'
import { EditorState } from "draft-js";
import createInlineToolbarPlugin from "draft-js-inline-toolbar-plugin";
import createSideToolbarPlugin from "draft-js-side-toolbar-plugin";

import Editor from "draft-js-plugins-editor";

const inlineToolbarPlugin = createInlineToolbarPlugin();
const { InlineToolbar } = inlineToolbarPlugin;
const sideToolbarPlugin = createSideToolbarPlugin();
const { SideToolbar } = sideToolbarPlugin;
const plugins = [inlineToolbarPlugin, sideToolbarPlugin]

export default function CreatePost() {
const editor = React.useRef(null);

const [editorState, setEditorState] = React.useState(
    EditorState.createEmpty()
);

return (
    <>
        <Layout>
                <Editor
                    editorState={editorState}
                    onChange={editorState => setEditorState(editorState)}
                    plugins={plugins}
                    ref={editor}
                />
                <InlineToolbar />
                <SideToolbar />
        </Layout>
    </>
)

}`

Thanks for ur help.

bug stale

All 3 comments

I have this issue too. as soon as i resize my browser

I have the issue as well.

Maybe it has something to do with SSR.... Next.js is known to have problems with reading window properties as it can only access the window object on the client and not on the server

https://medium.com/frontend-digest/why-is-window-not-defined-in-nextjs-44daf7b4604e

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jamesfzhang picture jamesfzhang  路  3Comments

kaustubh-karkare picture kaustubh-karkare  路  3Comments

GaborLeskoFlach picture GaborLeskoFlach  路  3Comments

Hongbo-Miao picture Hongbo-Miao  路  3Comments

sessionboy picture sessionboy  路  3Comments