Skip to content

How to correctly import an external stylesheet with import syntax? #2015

Closed Answered by ocavue
Yokubjon-J asked this question in Q&A
Discussion options

You must be logged in to vote

The main issue is that Remirror is a client library that's dependent on browser API like document and window. It's not a good idea to render it as some HTML string on the Node.js server.

You will need to use some method to skip rendering Remirror on the server, and only load Remirror on the browsers. In React you will need lazy and Suspense for this: https://react.dev/reference/react/lazy

For your example, I can fix it by adding a new public/EditorLazy.jsx with the following content:

// public/EditorLazy.jsx
import { Suspense, lazy, useEffect, useState } from 'react';

const Editor = lazy(() => import('./Editor.jsx'));

export default () => {
    const [isClient, setIsClient] = useState(f…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@Yokubjon-J
Comment options

@ocavue
Comment options

Answer selected by Yokubjon-J
@Yokubjon-J
Comment options

@Yokubjon-J
Comment options

@Yokubjon-J
Comment options

@Yokubjon-J
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants