Comments (2)
Recently faced the same issue. I got it working in a very hacky way, until novel
supports it natively.
So basically, in the component where I'm rendering EditorContent
, there is an early return like this
if (!initialContent) null
The issue is initialContent
doesn't respond to changes for obvious reasons. And what works in this case is, setting the initialContent
to null before changing. In my case, something like this
flushSync(() => {
setSelectedNote(null);
});
setSelectedNote(noteId);
Since initialContent
prop is derived from the selectedNote
state, that also becomes null and the editor content changes on the next render.
from novel.
Recently faced the same issue. I got it working in a very hacky way, until
novel
supports it natively.So basically, in the component where I'm rendering
EditorContent
, there is an early return like thisif (!initialContent) null
The issue is
initialContent
doesn't respond to changes for obvious reasons. And what works in this case is, setting theinitialContent
to null before changing. In my case, something like thisflushSync(() => { setSelectedNote(null); }); setSelectedNote(noteId);
Since
initialContent
prop is derived from theselectedNote
state, that also becomes null and the editor content changes on the next render.
This approach worked!
Instead of flushSync I used a short setTimeout to update the states in the same useEffect without React warnings.
Thank you so much! You saved me!
from novel.
Related Issues (20)
- bug: cannot remove a selected link in the bubble menu
- bug: yarn novel can't find novel/extensions module HOT 1
- Need help running the example.
- feat: table support
- TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))bug: HOT 5
- feat: Can drag custom react components
- ⚠ TS Errors need to be fixed on null of editor for lastest version of Novel HOT 2
- 🐞bug: editable={false} doesn't prevent editing content HOT 1
- feat: Possibility to await a slash command and display a loading spinner?
- feat: Easy way to reference the editor outside the EditorContent HOT 2
- Error after typing any character after '/' HOT 4
- feat: Support for custom Open AI API URL HOT 1
- bug: codeblock-lowlight doesn't render in html output HOT 1
- Cannot find module 'novel/extensions' or its corresponding type declarations. HOT 2
- Cannot set text color when the text is bold HOT 1
- Cannot import Editor from novel bug: HOT 1
- feat: For novel-vue, is there a way to integrate image upload to display as base64?
- feat: add a EditorCommandSeparator
- feat: Allow Markdown and Html in InitialContent HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from novel.