[NextJS] Editor main css being removed on Head change
See original GitHub issueDescribe the bug
It seems that when we change the favicon of a NextJS app, the editor.main.css
link is removed from the <head>
.
To Reproduce
Steps to reproduce the behavior:
- Go to https://codesandbox.io/s/monaco-nextjs-gcd5d?file=/pages/index.js
- Click twice on the button
- The second time the editor is rendered without styles
- If you comment the
<Head>
portion of the code, everything works fine
Screenshots
Desktop (please complete the following information):
- OS: [e.g. iOS]
- Browser Chrome
- Version v4.2.1
Issue Analytics
- State:
- Created 2 years ago
- Reactions:14
- Comments:11 (3 by maintainers)
Top Results From Across the Web
next/head removing injected scripts · Issue #11012 - GitHub
next/head is removing scripts added into head. This issue is currently causing the removal of scripts injected by our third-party tag manager.
Read more >next/head | Next.js
The contents of head get cleared upon unmounting the component, so make sure each page completely defines what it needs in head ,...
Read more >Advanced Features: Next.js Compiler
Learn about the Next.js Compiler, written in Rust, which transforms and minifies your Next.js application.
Read more >Advanced Features: Custom `Document` - Next.js
Inside app/ , you can modify the initial html and body tags using a root layout. ... import { Html, Head, Main, NextScript...
Read more >Basic Features: Handling Scripts - Next.js
There are a number of trade-offs that need to be considered when loading a third-party script in a web worker. Please see Partytown's...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you @suren-atoyan I “fixed” this issue adding the style manually
Thanks, @relferreira @suren-atoyan ! I spent a lot of time trying to debug the visibly broken React Monaco Editor whenever React Fast Reloading / Hot Module Reloading kicked in.
Took me a while to realize the CSS file was being removed causing the minimap to be moved to the wrong position, and gutter line numbers and cursor to be missing entirely.
I created a new React component to use instead of Monaco React directly:
CodeEditor.tsx
:Then applied:
Hope the above helps others, too!
Thanks again everyone!