Below is my draft:
I have a working code to have 2 search bars with dropdown suggestions, selectable by both mouse and arrow keys in TypeScript and Fresh/Preact. In there I have to explicitly declare individual hooks and containers for different lists.
Pieces of working code
In an attempt to modularize it, I attempt to set hooks for the hooks:
Pieces of hooks of hooks
It doesn't work. Why is it the case?
My next step for this is to have the suggested lists disappear when they are unfocused by integrating it with Detect click outside multiple components
The draft is about what I've learned, tried, intended, struggled and questioned about, and it's more about helping myself think better and clearer. I don't intended to write it to any specific site. From my feeling SO will accept it – but that's a trivial fact – and CR won't like the why the try doesn't work – but I don't have any exposure to the site to confirm that. That's why I ask this question.
Bending the question to follow the site better is fine for me. It's just that I think if adding the attempt is fine, then when it doesn't work it's natural for the readers to be curious on why. So having a side, off-topic question on why it doesn't work in a main, on-topic one is acceptable, as I think answers including it enhance the learning better.
Should I just ask how to improve the working code without mentioning my try? It can be asked in SO. Or is it fine to include to the post?