-
-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use$ does not work with React Compiler #477
Comments
Well this is fascinating. Compiler seems to be breaking For now you could use |
Ok yes, the problem is that Compiler is currently not considering export function isHookName(name: string): boolean {
return /^use[A-Z0-9]/.test(name);
} So I'm going to file an issue on the react repo and see what we can do. I'll post back here with any updates. |
I cannot provide you with any data or tangible evidence for the following, so take it with a grain of salt. I'm sensing a general distaste in the webdev community for $-notations or any custom syntactic sugar for that matter. It has been quite a bumpy ride for the dollar-notation in Svelte (used for accessing stores - will probably be removed in the next version) and especially in the React world "custom looking code" is not received very positively (completely anecdotal). I believe, people might think that there is some functionality attached to the $ and be put off by this amazing library because it looks different than your regular React code - even though it practically is. Anyway, I love this library keep up the great work. I'll see myself out. |
@peterkogo and others: is there a hook name that you think would be better than My current favorite alternative ideas:
|
Hi, @jmeistrich, I can't thank you enough for your amazing work on Legend-State and and Legend-List! Regarding the hook name, here are a few thoughts:
Once again, thank you for everything you’re doing—it truly makes a difference! |
I saw in several codebases that people often use $ to indicate that whatever variable is an observable. And I am personally is totally fine with But frankly, this feels like choosing between potato and potato. It's always possible to re-export the hook with a different name. If there is still an option, I'd say |
useWatched, useTracked or useValue are all good options (useValue being my favourite, it's marginally shorter and feels like the meat-and-potatoes building block that it's intended to be). |
useTracked is however my favorite. Whatever function you pass in there is evaluated in "tracked" context. Tracking seems to be the word signal libraries landed on to describe the context in which subscriptions through calling getters are actually considered. Both Svelte and SolidJS make use of this word. It would also make the documentation for this function clearer with adopting the idea of 'tracking context' instead of differentiating between observables & computation functions. Makes the way it works together with
It returns an untracked observable. Though, it can be tracked via |
observable -> create observable -> createStore or better: observable -> createObservable |
Hello,
Thank you for an amazing work with legend-state.
I have noticed that v3@beta is not friendly with react-compiler.
Reproduction
pnpm vite # to start the app
It has two identical components subscribed to the same store. One component uses react-compiler, another does not.
When you click on the button, "non-react-compiled" component re-renders, and another does not.
Please let me know if you need any additional information or a help debugging it.
The text was updated successfully, but these errors were encountered: