Chris P Bacon
Chris P Bacon
SSolidJS
Created by hyperknot on 2/16/2025 in #support
Understanding Solid reactivity with console.log
I always do the createEffect + console.log. But I will look into the devtools package you mentioned, I do not know of it
35 replies
SSolidJS
Created by hyperknot on 2/16/2025 in #support
Understanding Solid reactivity with console.log
what I'd do in this case is probably merge the uistate and docs and utilize createSelector this would then also fix your leaky abstraction and circular references
35 replies
SSolidJS
Created by hyperknot on 2/16/2025 in #support
Understanding Solid reactivity with console.log
well, you have to calculate all of them no? the definition of isActive is if the doc's id is the same as the selectedId. so if you change the selectedId then you will need each item to check if that id is the same as theirs
35 replies
SSolidJS
Created by hyperknot on 2/16/2025 in #support
Understanding Solid reactivity with console.log
but all your items run the memo itself to calculate if there is a change
35 replies
SSolidJS
Created by hyperknot on 2/16/2025 in #support
Understanding Solid reactivity with console.log
because with your memo you should only get 2 items that actually rerender, the one that loses the active state, and the one that gets it
35 replies
SSolidJS
Created by hyperknot on 2/16/2025 in #support
Understanding Solid reactivity with console.log
depends on what you mean as a rerender. like an actual render that you could make visible with devtools? or do you mean the reactivity system doing its job?
35 replies
SSolidJS
Created by hyperknot on 2/16/2025 in #support
Understanding Solid reactivity with console.log
alright, gotcha. Guess I've never run into this due to my general aversion to global stuff. I always just opted for a context instead.
35 replies
SSolidJS
Created by hyperknot on 2/16/2025 in #support
Understanding Solid reactivity with console.log
just for my understanding than. isn't it bad practice to create that stuff outside of the render tree? I always avoid creating top level signals and such for the same reason. or at least I think it is for the same reason
35 replies
SSolidJS
Created by hyperknot on 2/16/2025 in #support
Understanding Solid reactivity with console.log
aaaah, gotcha
35 replies
SSolidJS
Created by hyperknot on 2/16/2025 in #support
Understanding Solid reactivity with console.log
if you just wish to log the one or two Doc's that actually changed than you want to add a createEffect that logs the isActive memo. then you would only see the numbers that did change
35 replies
SSolidJS
Created by hyperknot on 2/16/2025 in #support
Understanding Solid reactivity with console.log
so to summarize, the reason you are seeing all the numbers being logged is because each and every Doc is answering the question if it is active or not.
35 replies
SSolidJS
Created by hyperknot on 2/16/2025 in #support
Understanding Solid reactivity with console.log
aaaaah, I see why, you are using uiStore.state.activeDocID inside of your memo. since the uistore is also a reactive store this means that your memo is tracking both the internal store of the doc itself. and also the uistore. This is also the behavior you want, because otherwise your isActive would never update.
35 replies
SSolidJS
Created by hyperknot on 2/16/2025 in #support
Understanding Solid reactivity with console.log
I'm still trying to decypher the code to understand why your memo is triggering for each and every click. A couple of things that I initially spot that might or might not be a cause of your bug: 1. the circular dependency of uistate.js and doc.js is either already, or will in the future, cause you problems 2. why are you calling createRoot? this is a helper from solid which in meant to initialize the reactive system, so normally you only do this once in order to 'mount' solid to the DOM.
35 replies
SSolidJS
Created by Chris P Bacon on 2/10/2025 in #support
How to dynamically 'render' a string interweaved with `<span />`'s
p.s. I'm going to close this question, it is straying way too far from it's original question.
18 replies
SSolidJS
Created by Chris P Bacon on 2/10/2025 in #support
How to dynamically 'render' a string interweaved with `<span />`'s
that is what I've done, which is also where the 'error' comes from. let's say I am at position x and I press a key in order to insert a letter. so before the insertion I store the cursor position, let the insert and rerender happen, then restore the cursor to pos x. well, that's wrong, because you are now at x+1. that's what I meant earlier. I realize now that I likely was not clear. I was sharing my thoughts, not asking a question. sorry for the confusion. I managed to solve the whole editor thing for the most part, pretty happy with where I ended up. Besides the spelling and grammar checking I also wanted to do bi-directional conversion between markdown and html. So I implemented a solution usinf unified with remark and rehype. and for error marking I created a plugin that adds the nodes to the ast instead of trying to insert it into the string as html. In case you are curious: https://github.com/chris-kruining/calque/blob/main/src/features/source/source.ts
18 replies
SSolidJS
Created by Chris P Bacon on 2/10/2025 in #support
How to dynamically 'render' a string interweaved with `<span />`'s
to make sure the behavior is as expected. All of this suff I'd happily skip, but the cursor gets reset to the start, since every rerender creates new nodes.
18 replies
SSolidJS
Created by Chris P Bacon on 2/10/2025 in #support
How to dynamically 'render' a string interweaved with `<span />`'s
I think you are on the money! I've actually for the most part managed to solve my issue by using the selection solid primitive. it is a really nice wrapper around the native selection API! Only issue I have left to solve is that I need to figure out what mutations to the text cause which mutations to the cursor position. i.e. when you insert 1 character the cursor should advance by 1.
18 replies
SSolidJS
Created by FatFreeButter on 2/11/2025 in #support
Dependency error using npm init solid@latest
ooooh, seems vinxi got updated yesterday 🥳 https://github.com/solidjs/solid-start/pull/1778
17 replies
SSolidJS
Created by FatFreeButter on 2/11/2025 in #support
Dependency error using npm init solid@latest
pretty sure you could clear out all the dev-deps for instance. and many of the other deps are nice-to-haves I think
17 replies
SSolidJS
Created by FatFreeButter on 2/11/2025 in #support
Dependency error using npm init solid@latest
this is the complete list of deps I use atm, you'll want to cherry pick which ones you wanna keep
17 replies