D
Deno

help

useEffect in the islands

Kking8fisher9/19/2023
Seeing a strange error in the browser window as soon as I add a simple as
useEffect(() => {
console.log('here');
});
useEffect(() => {
console.log('here');
});
No description
Kking8fisher9/19/2023
I'm basically using this structure on an island:
if (IS_BROWSER) {
useEffect(() => {
console.log('here');
});
useSignalEffect(() => {
// ...
}
if (IS_BROWSER) {
useEffect(() => {
console.log('here');
});
useSignalEffect(() => {
// ...
}
I hope someone has had something similar, any hints,
Kking8fisher9/19/2023
The exception is happening from this snippet:
No description
DAHDeno AI Helper9/19/2023
I'm sorry to hear that you're having trouble. However, the documentation does not provide any specific information about the use of useSignalEffect and useEffect together. It would be helpful if you could provide more details about the error message you're seeing. In general, useEffect is a hook from Preact (or React) that runs side-effects in your component, such as fetching data, setting up subscriptions, or manually changing the DOM. useSignal is a hook from Preact Signals, a state management library for Preact, that creates a reactive state signal. If you're seeing an error, it could be due to a variety of reasons such as incorrect usage of hooks, issues with dependencies, or conflicts between different pieces of state. As a debugging step, you could try isolating the issue by removing other code and seeing if the error still occurs with just the useEffect hook. If the error persists, it could be an issue with how your project is set up. If the error goes away, you can gradually add back other parts of your code to see what's causing the conflict. Remember, this advice isn't from the documentation, but it's a general approach to debugging issues in code. ๐Ÿฆ•
Kking8fisher9/19/2023
Added a reproducible case: https://github.com/king8fisher/fresh-example/tree/demonstrate-use-effect-issue demonstrate-use-effect-issue branch @marvinh. tagging you since you replied to original message
GitHub
GitHub - king8fisher/fresh-example at demonstrate-use-effect-issue
Contribute to king8fisher/fresh-example development by creating an account on GitHub.
Kking8fisher9/19/2023
To be even more precise, it seems to break even when just a single useEffect is used. Collecting some notes from other issues to come out with a "rule of thumb".
Kking8fisher9/19/2023
GitHub
Can't define signal in async component or when using defineRoute ยท ...
I just tried making the Home function in a default 1.4.1 project into async and also tried using the new defineRoute method, but I got an error: An error occurred during route handling or page rend...
Kking8fisher9/19/2023
https://github.com/denoland/fresh/issues/1540 I think I found the issue @marvinh. It's a very smart auto-import.
Mmarvinh.9/19/2023
oh no ๐Ÿ˜… haven't had a chance to look at that yet
Kking8fisher9/19/2023
No problem I had to figure it out anyway ๐Ÿ˜„ It attempts to auto-import like so: import { useEffect } from "https://esm.sh/v128/preact@10.15.1/hooks/src/index.js"; and in reality it has to be .... from "react/hooks"; I've been bamboozle heavily.
Mmarvinh.9/19/2023
ohh yeah, that likely lead to two different versions of Preact running at the same time. Hooks must use a singleton by design and both library versions can't see each other's variables
Kking8fisher9/19/2023
I'm sure I'll be bumping into this a lot. Leaving it as a no-fix issue for myself. (https://github.com/king8fisher/fresh-example/issues/1) Possibly: VSCode extension showing a bit more as to where the import is going to come from, as it shows 5 for useEffect and the first one in the list is surely enough the wrong one.
GitHub
Uncaught (in promise) TypeError: Cannot read properties of null (re...
This issue is not for fixing. It's to demonstrate how uncareful importing of a wrong function from the list that VSCode is providing can lead to hours of hunting for a non-existing bug. 54bedaf...

Looking for more? Join the community!

Recommended Posts
Basic react server side rendering does not work on Deno Deploy but does locallyThe below application work correctly locally but fails on Deno Deploy. On Deno Deploy, all my responode cryptoHey everyone, can you explain why certain packages such as node/crypto are not included in newer verPretty new to Deno, what is the recommended way to create a monorepo-like in Deno ?Everything is in the question. I tried during the entire week-end to get up & running with monorepo-[fresh] injecting css into head in a componentWhen I inject css in the head of my html in a component, it works perfectly, but when I reuse the coAutosave firing on editing `.ts` files when a separate Deno enabled project is openHello, I am working on slack automation using deno. I'm developing with webstorm, but I'm having a pProblem with parsing `base64url` from a `Buffer (node)`help , it works in bun but not in Deno, I don't know if is a bug from them or it's not implemented hUUID of managed KV databaseHello, I am trying to follow [this doc](https://docs.deno.com/kv/manual/on_deploy#connect-to-managedError at the execution of a programmHey ! I have a problem when i run one of my programm with deno, is a programm made with typescript Can't import typescript moduleWhy can I only import the js file and not the ts file? ```js import * as zip from "https://deno.lanIs there a way to change the default Details of the compiled exeI esentialy want to change the comiling defaults of the details and the image of the resulting exe (Setting source map root with `deno_emit`Hello! I'm currently trying to use `deno_emit` so bundle some assets. The code bundles properly, howIn Deno, what is the best way to simply host static websites?What is the best way to simply host static/cached files? Without having to do a read file call everyzsh: command not found: deno on macOSplease send helpUsing esbuild with import mapsHello ๐Ÿ‘‹ I'm attempting to migrate one of my front-end projects to using Deno for tooling instead ofproxy-agent not working on Deno DeployI'm trying to use a proxy for the node-fetch requests in a deno app. I chose proxy-agent npm packagExtremely high CPU usage in Windows running on Intel Pentium processorI have a simple app (about 300 lines of code, few deps). I compile it into a Windows executable. WheImpossible to use `"jsx": "preserve"` in deno.json...Well it seems that I can't use jsx preserve in deno.json, when I try to run any tasks in deno.json, integrating deno_webOk I seem to have poobrain today. Can't seem to get the deno_web extension working. The core versioCan I use Workers in an executable ?Everything is in the questions, on the doc site, it is mention that we can't use Workers when creatiWalkSync dosnt get filesIm trying to read all files of a folder with WalkSync from the deno STD libary but it dosnt see the