#Export from `.client` file?
1 messages · Page 1 of 1 (latest)
any .client file will give you an empty object as export on the server
you need to check client-side only
You mean the remix-utils thing?
// app/something.client.ts
export function sum(a: number, b: number) {
return a + b
}
// app/routes/_index.tsx
import { sum } from "~/something.client"
export default function Component() {
useEffect(() => {
console.log(sum(1, 2))
})
return null
}
I meant on the browser, depending on what your module exports you may not need ClientOnly from Remix Utils
if you're exporting just a function you can use it in an effect or event listener
if you're exporting a React component you need to wrap it in ClientOnly
I'm just exporting an object but I'm exporting it to an XState machine, so useEffect isn't available.
Should I do:
window.addEventListener("load", function);
...I'll give that a shot.
...that didn't work. window is undefined in the machine file now.
the problem is you need to ensure the file only runs client-side, the extension avoids shipping the code to the server, but if you try to call it server-side it will fail
I was just reading this:
The only issue is ClientOnly breaks in v2..
Is that true?
https://stackoverflow.com/questions/74910021/adding-a-client-suffix-to-my-jsx-or-tsx-file-breaks-the-import-in-remix
it works perfectly fine
I just want to use Remix 1.6 for the rest of my life. That was awesome. Nothing works anymore.
I have been using the latest minor of v1 for months now, you don't need to upgrade
I think the issues this person mentions is probably because the v7 of remix-utils tha requires ESM or to use serverDependenciesToBundle
I'm having issues with the new routing system also. I tried using this but I started getting errors, so I gave up on it.
https://www.npmjs.com/package/@remix-run/v1-route-convention
What was the last version of Remix that used the old routing system? You say, I can still use that?
Enables the v1 route file convention in Remix v2.. Latest version: 0.1.4, last published: 2 months ago. Start using @remix-run/v1-route-convention in your project by running npm i @remix-run/v1-route-convention. There are 2 other projects in the npm registry using @remix-run/v1-rout...
Doesn't the later versions of v1 use the new routing system>
?
by default it comes with the v2 convention enabled, but you can disable it in the remix.config.js
Oh
just set v2_routeConvention: false
every future flag is enabled by default but you can disable them