-
Notifications
You must be signed in to change notification settings - Fork 337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cant find variable document on React Native #39
cant find variable document on React Native #39
Comments
The reason why this issue is happening is because, react-hot-toast has a dependency on goober and goober internally uses the HTML Document object which is not present in react native.. I too want to use this library for my react-native projects... |
Oh, you are right. I was able to reproduce this. It seems like this was caused by
|
Same thing here. @timolins thanks for taking a look! My guess is it's caused by use of Adding |
Solved it for now by using https://github.com/ds300/patch-package and just removing everything |
Workaround: change and when creating a toast use:
|
This is weird, I tried to use I can't seem to find a reason why this should happen when comparing v1.0.0...v1.0.1 - this is the update when it stopped working. |
This comment has been minimized.
This comment has been minimized.
Is react-native working in the latest version of react-hot-toast? Hoping to try it again. |
The answer is no. However, 1.0.0 does work. Snack: https://snack.expo.dev/@nandorojo/2fce9a try changing 2.1.0 → 1.0.0 in package.json. That's the only solution. |
@timolins I think one solution could be to add this to the the {
"react-native": "./src/index.ts"
} This would direct native apps to go directly to the source code. This is common practice, since native apps transpile node modules. To that end, there could be a file that only exports the headless components:
export ... // export all the non-web files here And then in export * from './headless'
// then export the web-only things here The final step here, would be to let users import from Similar to how SWR does this, we could add an {
"exports": {
"./package.json": "./package.json",
".": {
"import": "./dist/index.js",
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./headless": {
"import": "./dist/headless.js",
"require": "./dist/headless.js",
"types": "./dist/headless.d.ts"
},
},
} I'm not sure what your build script is doing, but it seems like the |
Great idea. Yes I'd be open for that. I'm using TSDX under the hood for the build. I think it should possible to get an output like this. I'm limited on time right now, would you mind submitting a PR? (If not I can have a look in ~2-3 weeks) |
@timolins @nandorojo Were you able to look into this? |
+1 for any progress on this? |
This gives us more control about the build process * Expose `react-hot-toast/headless` - Fixes #39 * Bundle size is even smaller now TODO: * Find alternative for `tsdx lint` and possibly `tsdx test`
Bump! I'd love to use this in my project. I've gotten used to it. |
Hey,
Iam trying to use this library inside react-native, however I keep getting
I have this notifcation component:
and I use that instead of
<Toaster />
Apart from that the only imports I do look like this:
The text was updated successfully, but these errors were encountered: