-
Notifications
You must be signed in to change notification settings - Fork 12
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
useReplicant contains stale values when using a different repName/namespace. #3
Comments
Trying to test it locally so I cloned the project. Getting a cryptic error when I try to run the test. Using yarn and the newest version of node (11.14), adding an exception to engines so that yarn can install it. This happens even if I run build first
|
Recently my impression is we probably should change the API to pass replicant instance instead of replicant name. |
@CarlosFdez @tedkulp I would be interested in what you think about the idea above. |
In the case of this bug, I was able to fix it locally by adding replicant as a dependancy to useEffect, which is what the linter recommended I do anyways. Only problem is that I couldn't get the tests to work on my machine so no way I can submit a PR. As far as that API change is concerned though, I'm fine with that, however I can imagine that being a bit verbose for the common case. Luckily, its pretty easy to detect if the first parameter is a string or if its a replicant, so I think its very possible to support both. IMO my personal thought is that if breaking changes are not something we're concerned about, it should support both |
Supporting both with the same hook would make more confusion than the benefit (of either) IMO. The way would be making another hook function. As for the tests, the problem seems to be because of the lack of |
Probably so, not particularly agreeing but that said I'm used to function overloading since nearly every language out there supports it, so its your call. That said replicantOptions is much more flexible than intialValue for the take a name case, as it also contains its own initial value. Turns out that locally I solved it by using repName, not replicant. I'll have to see if nodecg caches Replicant instances cause otherwise it'll cause problems, especially if a version is made that takes a replicant directly. What would I put in prettierignore? Never used prettier before. It seems that prettier is using a whitelist already (that is including md, yaml and json?) |
For prettierignore, you can just copy paste the content of gitignore. |
Didn't work, same issue just with less entries in the list.
When I swap to --check (did a bit of research), it says that those are code style issues, so it seems like the issue is just something regarding the current version. However it doesn't seem like npm run test actually runs any tests and I was probably led astray by a red herring. |
I can look into it if you could submit the PR. |
luckily npx jest works, its just that npm run test doesn't call it. There's a broken test in the current version so might as well try to fix it. Figured that out after I sent the previous message but there should be no problem. |
I do have a few questions though. Currently I'm trying to fix the bug as its not decided what the new API will be. It also turns out that what I reported isn't exactly right. The problem isn't specifically with namespaces, its with replicant name prefixes. nodecg-obs calls it a namespace but its not actually a namespace, its just a replicant name prefix ('compositor:websocket
|
|
However I just added eslint-plugin-react-hooks and it seems it wants me to use replicant regardless, so the question has been answered: mimic live functionality.
Checking for undefined is extremely annoying in javascript. Trying to do it Python style (check for falsy) but linter doesn't like it... |
Just gonna solve 2 like this. I really don't like javascript's coalescing capability but unfortunately I can't change it: const repName = |
Fixed in #7 |
Currently, swapping out the namespace using a prop does not cause useReplicant to use the new replicant name. My suspicion is that its because the internal useEffect never runs on subsequent re-renders.
Here's a gist where this problem manifests. The "OBSControlView" object always binds to the first namespace, even if the prop changes.
https://gist.github.com/CarlosFdez/ab3ab575a62c048daacb8f6b38a6f2d3
My suggestion is to add repName as a param to line 39. I wanted to ask here for the go-ahead before doing it.
The text was updated successfully, but these errors were encountered: