GithubHelp home page GithubHelp logo

Comments (20)

YousefED avatar YousefED commented on May 20, 2024 2

Fyi, nextjs should work more straightforward as part of v0.5.1: https://github.com/TypeCellOS/BlockNote/releases/tag/v0.5.1. dynamic is no longer needed

from blocknote.

YousefED avatar YousefED commented on May 20, 2024 1

Does this work for you?

DynamicBlockNote.tsx:

import "@blocknote/core/style.css";
import { BlockNoteView, useBlockNote } from "@blocknote/react";

function Editor() {
  const editor = useBlockNote({});

  return <BlockNoteView editor={editor} />;
}

export default Editor;

index.tsx (or any other next page)

// top of file
const BlockNote = dynamic(() => import("./DynamicBlockNote"), {
  ssr: false,
});

...
// in your render() function:

<div style={{ width: "500px;height:300px;background:white" }}>
    <BlockNote />
</div>

from blocknote.

ishan-flek-ai avatar ishan-flek-ai commented on May 20, 2024 1

I tried this. It doesn't solve the problem.

from blocknote.

YousefED avatar YousefED commented on May 20, 2024 1

This demo works for me: https://github.com/YousefED/blocknote-examples-nextjs/pull/1

Are you using NPM or a different package manager?

from blocknote.

ishan-flek-ai avatar ishan-flek-ai commented on May 20, 2024

Tried it on a brand new next app using create-next-app and was able to reproduce this error. Tried main repo and running the example and I am not getting the error. In the next app I have also disabled ssr on the page this is loading using dynamic still getting this error.

So looks like next specific error.

from blocknote.

ishan-flek-ai avatar ishan-flek-ai commented on May 20, 2024

packages/core/src/shared/utils.ts
packages/react/src/utils.ts

export const isAppleOS = () => {
  // FIXME: Code causing issues in SSR
  // /Mac/.test(navigator.platform) ||
  // (/AppleWebKit/.test(navigator.userAgent) &&
  //   /Mobile\/\w+/.test(navigator.userAgent));
  return false;
};

from blocknote.

steven-tey avatar steven-tey commented on May 20, 2024

Running into this error as well using Next.js 13 App Router. Will investigate!

from blocknote.

steven-tey avatar steven-tey commented on May 20, 2024

Update: Still stuck on this – looks like importing with next/dynamic does remove the error but doesn't render the actual component. Here's my code:

"use client";

import dynamic from "next/dynamic";
const BlockNoteView = dynamic(
  () => import("@blocknote/react").then((mod) => mod.BlockNoteView),
  {
    ssr: false,
  }
);
const useBlockNote = dynamic(
  () => import("@blocknote/react").then((mod) => mod.useBlockNote),
  {
    ssr: false,
  }
);
import "@blocknote/core/style.css";

export default function Editor() {
  const editor = useBlockNote({
    onUpdate: ({ editor }) => {
      console.log(editor.getJSON());
    },
  });

  return <BlockNoteView editor={editor} />;
}

from blocknote.

steven-tey avatar steven-tey commented on May 20, 2024

Yeah same - dynamically importing from @blocknote/react gave me an undefined value for useBlockNote

from blocknote.

steven-tey avatar steven-tey commented on May 20, 2024

Ooooh this 0.4.6-alpha.3 version worked!! Thank you!

from blocknote.

oalexdoda avatar oalexdoda commented on May 20, 2024

Next.js completely broken due to the navigator error. Any fix coming? @YousefED ?

from blocknote.

YousefED avatar YousefED commented on May 20, 2024

Next.js completely broken due to the navigator error. Any fix coming? @YousefED ?

Have you tried the version / demo above? Are you still encountering issues?

from blocknote.

YousefED avatar YousefED commented on May 20, 2024

I'm closing this issue as I think NextJS should be fixed as part of 0.4.6-alpha.3 and there's a working demo @ https://github.com/YousefED/blocknote-examples-nextjs

from blocknote.

Kay2dan avatar Kay2dan commented on May 20, 2024

Unfortunately, I have the same issue:

ReferenceError: navigator is not defined

BlockNode: 0.5.0
NextJs: 12.2.5

from blocknote.

YousefED avatar YousefED commented on May 20, 2024

@Kay2dan could you share a reproducible sandbox / repo?

from blocknote.

Kay2dan avatar Kay2dan commented on May 20, 2024

from blocknote.

adamk22 avatar adamk22 commented on May 20, 2024

I just installed 0.5.0 in combination with "next": "13.1.2", and also getting this error.

from blocknote.

YousefED avatar YousefED commented on May 20, 2024

from blocknote.

adamk22 avatar adamk22 commented on May 20, 2024

I'm using node v16.14.2 (npm v8.5.0). I also tried the dynamic import fix you mentioned earlier and that seems to do the trick for now!

from blocknote.

adamk22 avatar adamk22 commented on May 20, 2024

0.5.1 fixed the issue completely for me (without dynamic imports). Thank you!

from blocknote.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.