Closed Legonois closed 1 month ago
<p>
component has childUnhandled Runtime Error
Error: Hydration failed because the initial UI does not match what was rendered on the server.
See more info here: https://nextjs.org/docs/messages/react-hydration-error
In HTML, <pre> cannot be a descendant of <p>.
This will cause a hydration error.
<Dev>
<div>
<StripeBackDrop>
<div>
<div>
<Card>
<div>
<p>
^^^
<pre>
This happens when rendering the actual lexical editor, as it is a child of the card. So I have to figure out where its going wrong
edit: SOLVED So, stupid thing, that hydration error was because I used a query function wrong in the same page, that is 100% on me.
Prepopulating the editor with nodes has felt impossible! I found a code base that does it properly, and my own nextjs project even works earlier, but as I began to rewrite the editor, it just stopped working!
This is my starting point, using a forked version of the Lexical monorepo.
Lexical/examples/react-rich/src/App.tsx
function $prepopulatedRichText() {
const root = $getRoot();
if (root.getFirstChild() === null) {
const heading = $createHeadingNode('h1');
heading.append($createTextNode('Welcome to the playground'));
root.append(heading);
}
}
const editorConfig = {
EditorState: $prepopulatedRichText, // Added for the editor state!
namespace: 'React.js Demo',
nodes: PlaygroundNodes, // Copied the node imports from the playground demo
// Handling of errors during update
onError(error: Error) {
throw error;
},
// The editor theme
theme: ExampleTheme,
};
When running this, it straight up doesn't change the default editor state. Still trying to figure out why tbh.
We need type error support in lexical to prevent his
function $prepopulatedRichText() {
const root = $getRoot();
if (root.getFirstChild() === null) {
const heading = $createHeadingNode('h1');
heading.append($createTextNode('Welcome to the playground'));
root.append(heading);
}
}
const editorConfig = {
// EditorState: $prepopulatedRichText,
editorState: $prepopulatedRichText, // editorState should not be capitalized
namespace: 'React.js Demo',
nodes: PlaygroundNodes, // Copied the node imports from the playground demo
// Handling of errors during update
onError(error: Error) {
throw error;
},
// The editor theme
theme: ExampleTheme,
};
https://github.com/shadcn-ui/ui/issues/2944
Downgraded cmdk version so the combobox works properly
User Story
As a User, I would like to edit existing pages directly on the site
Criteria
Tasks