S
SolidJS•2y ago
Grahf

General component organization question....

Just wondering if there's a better way to organize this file:https://stackblitz.com/edit/solidjs-templates-gguy1g?file=README.md,src%2Fcomponents%2Fbook-parts%2FSlider.jsx It has a lot going on and just feels out of control to me.
3 Replies
fabiospampinato
fabiospampinato•2y ago
There seem to be a ton going on there, maybe: 1. possibly you'd want to make dedicated primitives that give you signals to the window height/width. 2. you can always increment/decrement the page but then clamp it between 0 and pageMax, that deletes the ifs around that. 3. the await in await scrollIntoView seems 100% useless, usually I think either you use then/catch/finally, or you use await and try..catch. 4. The .bookParagraphs selector is kinda random in there, usually selectors are not used pretty much at all in declarative frameworks. 5. effects that return something IMO are probably good candidates for writing things differently. Like you can just read book there, you don't need to explicitly keep track of the previous value. Possibly other things, it seems pretty long, components around 30 lines of code or so are much easier to reason about 🤔
Grahf
Grahf•2y ago
Yes it is way too much. Thanks I will start digging back into this component as soon as I have something resembling a working app again 🙂
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View