js
js
DDeno
Created by js on 5/30/2024 in #help
VS Code Settings
No description
3 replies
DDeno
Created by js on 5/28/2024 in #help
A way to render code only if JS code can't be run
I noticed (at least in development), that when the app refreshes due to code change, and if I press back button to go to a previous version of the app which is no longer valid, the app doesn't work (rightfully so, because the previous iteration of the dev app no longer exists). Interestingly, I noticed that the HTML code generated by previous version of the now non-existent app, stilll works. But this previous version of the app is static HTML, and JS does not work until I refresh the app. I'd like to know if it's possible to show a different code to ask the user to "refresh the page" if a user reaches this problem. Note: I have not tested this in production, so I do not know if this is a problem in production.
2 replies
DDeno
Created by js on 5/26/2024 in #help
Route redirect handlers
I tried using this code to redirect a route to another route.
export const handler: Handlers = {
GET(_req: Request, _ctx: FreshContext) {
const headers = new Headers();
headers.set('location', '/c/xyz');
return new Response(null, {
status: 302,
headers,
});
},
};
export const handler: Handlers = {
GET(_req: Request, _ctx: FreshContext) {
const headers = new Headers();
headers.set('location', '/c/xyz');
return new Response(null, {
status: 302,
headers,
});
},
};
It works-- its loading "/c/xyz" (correctly, as it should). But the URL doesnt' change. Is there a way to make this work AND change the URL?
9 replies
DDeno
Created by js on 5/25/2024 in #help
Using Deno.KV twice
I want to use Deno.kv twice. One in local memory and 1 persistent in database shared across multiple instances. Is that a good idea? And to do that, should I open two instances of Deno.openKv() in my app?
3 replies
DDeno
Created by js on 5/22/2024 in #help
Which standard lib do I use?
I see the docs referencing https://deno.land/std/ But I thought JSR is the new shiny thing? And everythign is referencing jsr:@std. So which stnardard lib do I use?
3 replies
DDeno
Created by js on 5/20/2024 in #help
Does preact useSignal() values need to be cleared for memory leak?
In react, I often had to do a if (mounted.current) {...} test to do something with reactive variables like states if I'm setting/using it after a Promise. If I use useSignal() from Preact, do I still have to check for if (mounted.current) {...} ?
1 replies
DDeno
Created by js on 5/17/2024 in #help
Should I be using memo() in Fresh (/components/ folder)?
If Fresh renders the files in /components/ folder as html, and returns no javascript, should I ever bother using memo() in anything inside the components folder?
1 replies
DDeno
Created by js on 5/16/2024 in #help
Deno Fresh: client side check dev or production
For my Deno Fresh app, I want to do a simple check from the client-side code to see whether it's in development mode or production deployed mode. Use case is: I want to point my API to my localhost if it's in development, otherwise point the API to production server. How can I do this in Deno Fresh?
2 replies
DDeno
Created by js on 5/16/2024 in #help
Deno is not defined
Is "Deno" supposed to be defined on the front-end client? I'm trying to get a simple app working using Fresh framework, but even on a fresh install of Fresh app, Deno is not defined in client, which causes a LOT of necessary Deno modules to not work (for example, "graphql-request"). Is this a bug on Deno? Or is there another way I'm suppose to do this?
3 replies