Comments (4)
Does preact pre-render have something like a "mount" lifecycle? some hook where you can specify "don't run this in the server, just run it on the client"? I think there are several libraries that uses the document directly, you might want to check how preact pre-render handle such libraries.
from notyf.
Hey! Hmm good catch. Just wondering, why do you need it to work on the head? scripts like this library are generally meant to be placed on the body bottom so that it doesn't block initial rendering and can also make use of the body.
Can you please give a bit more context on why you need it on the head? Maybe there's another way around.
from notyf.
It's just in my local development setup (CMS site). I have it in the head because otherwise there's a flash of unstyled content. I have a webpack dev server in use and the styles are injected when the script is executed. It's a minor issue but still a bit annoying 😄. It's kind of my issue maybe now when I think. I just wanted to let you know.
from notyf.
@ispal how did you end up fixing this?
FWIW, I get a similar error too using preact with pre-rendering:
Unable to read file: project-path/src/node_modules/notyf/notyf.es.js
ReferenceError: document is not defined
method: null
at: project-path/src/node_modules/notyf/notyf.es.js:120:22
Source code:
This is most likely caused by using DOM or Web APIs.
Pre-render runs in node and has no access to globals available in browsers.
Consider wrapping code producing error in: 'if (typeof window !== "undefined") { ... }'
Alternatively use 'preact build --no-prerender' to disable prerendering.
See https://github.com/developit/preact-cli#pre-rendering for further information.npm ERR! code ELIFECYCLE
Running preact build --no-prerender
as suggested does fix this problem, but the same thing happens as with @ispal where there's a flash of unstyled content.
@caroso1222 do you have any ideas?
Cheers
from notyf.
Related Issues (20)
- Using long text
- Link to the documentation flag as insecure HOT 1
- [Feature Request] Config option for a custom node to attach toast notifications HOT 2
- How to make a notification appear only once HOT 2
- Website SSL certificate expired HOT 2
- I don't know how to properly set the position value on vue? HOT 1
- Will this work inside of a shadow DOM? HOT 1
- How to make the notification called only once. And he didn't write it into the document every time he called.
- Is there a way to set position per call ? HOT 1
- esc key
- I want to change the z-index.
- Different position moves existing notifications
- All of my styling dosent work (vuejs(composition api) ,tailwindcss)
- Icons don't display on warn, info type
- Long text creates curve?
- Uncaught (in promise) TypeError: notyf is undefined HOT 1
- Pause timer when the window loses focus
- Add "style" attribute to package.json
- dismiss button does not have an accessible name
- When toast hidden time, need to callback some other function?
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 notyf.