Roren
Roren
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Roren on 4/17/2023 in #questions
CRA Alternatives for SPA
My issue is primarily one of optics. I fully recognize that as a rule, I should be able to do with Vite what I need to do. However, I need to be able to use the tool my employer allows. And there's a decent chance they say "npmtrends indicates Webpack is still head over heels more popular, and build time isn't a primary concern", and at that point I'll need to figure out how to rid us on CRA, while retaining Webpack and making the DX as good as it can be given those constraints.
14 replies
TTCTheo's Typesafe Cult
Created by Roren on 4/17/2023 in #questions
CRA Alternatives for SPA
Hey thanks! It looks like maybe I was misunderstanding, and Webpack can't be used with Vite (at least not easily). This is pretty old, but this issue would seem to suggest bundler isn't something that's really configurable: https://github.com/vitejs/vite/issues/1835
14 replies
TTCTheo's Typesafe Cult
Created by Roren on 4/17/2023 in #questions
CRA Alternatives for SPA
The only other question, which of course I can try and figure myself, would be if there's a relevant page in the docs that would be helpful if that becomes necessary you could link to.
14 replies
TTCTheo's Typesafe Cult
Created by Roren on 4/17/2023 in #questions
CRA Alternatives for SPA
Thank you so much for the timely and helpful response. That's fantastic.
14 replies
TTCTheo's Typesafe Cult
Created by Roren on 4/17/2023 in #questions
CRA Alternatives for SPA
Oh can you run a build through Vite with Webpack? I tried looking that up but didn't find any results. I might just be bad at looking.
14 replies
TTCTheo's Typesafe Cult
Created by Roren on 4/17/2023 in #questions
CRA Alternatives for SPA
That will 100% be the recommendation I will fight for. In the event that there is an extreme Webpack config, or it's determined they refuse to migrate off of Webpack, is the best option at that point to simply roll it manually to get rid of CRA?
14 replies
TTCTheo's Typesafe Cult
Created by Roren on 2/28/2023 in #questions
Reasons not to mutate React state
That's what springs to mind, but if there's anything else I can read please let me know, thank you very much 🙂
12 replies
TTCTheo's Typesafe Cult
Created by Roren on 2/28/2023 in #questions
Reasons not to mutate React state
Oh really? That's interesting! Do you mean, like, if I were to do something like...
const [user, setUser] = useState({ loginCount: 0 });

const mutate = () => {
user.loginCount++;
};

const update = () => {
setUser((prev) => ({
...prev,
loginCount: prev.loginCount + 1, // React doesn't track inappropriate mutations?
}));
};

const changeCount = () => {
mutate();
update(); // Even if mutate has run, update's setter still picks up 0 from prev?
};
const [user, setUser] = useState({ loginCount: 0 });

const mutate = () => {
user.loginCount++;
};

const update = () => {
setUser((prev) => ({
...prev,
loginCount: prev.loginCount + 1, // React doesn't track inappropriate mutations?
}));
};

const changeCount = () => {
mutate();
update(); // Even if mutate has run, update's setter still picks up 0 from prev?
};
12 replies
TTCTheo's Typesafe Cult
Created by Roren on 2/28/2023 in #questions
Reasons not to mutate React state
Just to tack on here, in this situation it might be worth updating state with a callback, rather than using the value returned from useState. You could setPerson((prev) => ({ ...prev, name: 'The Cooler Ed' })) instead, and that would ensure you're always referring to the most recent state value when the update occurs, rather than a potentially stale value
12 replies
TTCTheo's Typesafe Cult
Created by Roren on 2/28/2023 in #questions
Reasons not to mutate React state
Thank you very much for the responses, I really appreciate it.
12 replies
TTCTheo's Typesafe Cult
Created by Roren on 2/28/2023 in #questions
Reasons not to mutate React state
That all makes total sense. It seems like my understanding was correct, in that for the most part it's more so about what COULD happen as a result of unexpectedly updating state incorrectly, rather than an additional concrete consequence that WILL happen.
12 replies
TTCTheo's Typesafe Cult
Created by Roren on 2/28/2023 in #questions
Reasons not to mutate React state
I understand that this is the case - my question was more so intended to present what the person was doing in effort to mutate state, and ask about potential pitfalls that might be beyond my understanding. I appreciate you clarifying that point, though!
12 replies
TTCTheo's Typesafe Cult
Created by Roren on 2/8/2023 in #questions
SPA state in Zustand store being preserved across page navigation?
Can confirm this was the issue. You can listen for the pageshow event and check if event.persisted is true, and respond accordingly. Thank you guys as always, sorry for posting this and immediately closing it.
3 replies
TTCTheo's Typesafe Cult
Created by Roren on 2/8/2023 in #questions
SPA state in Zustand store being preserved across page navigation?
Looks like I've got some reading to do on BFCache, probably https://web.dev/bfcache/ I think I've got a solution for this in mind, but gonna check behind to make sure I implement it correctly.
3 replies
TTCTheo's Typesafe Cult
Created by Roren on 1/12/2023 in #questions
Infinite Error when React error boundary uses unrenderable MUI components
UPDATE: This seems to be due to the Dialog component adding a portal. I don't know the exact mechanics, but adding a disablePortal that will be passed to the DialogRoot (which is a styled Modal) seems to resolve this issue, if it suits your needs.
2 replies
TTCTheo's Typesafe Cult
Created by currenthandle on 11/19/2022 in #questions
Why is noUncheckedIndexedAccess enabled by default?
Particularly when working with others who may not have the same understanding about the conventions of the base, it's an extra safeguard and future-proofing.
47 replies
TTCTheo's Typesafe Cult
Created by currenthandle on 11/19/2022 in #questions
Why is noUncheckedIndexedAccess enabled by default?
It can be grating writing extra conditions to go-behind when you're pretty positive. But if the state of your app changes in the future, it may end up saving you from an insidious bug.
47 replies
TTCTheo's Typesafe Cult
Created by currenthandle on 11/19/2022 in #questions
Why is noUncheckedIndexedAccess enabled by default?
If "I know the types" were a good enough solution, TS wouldn't be useful.
47 replies
TTCTheo's Typesafe Cult
Created by currenthandle on 11/19/2022 in #questions
Why is noUncheckedIndexedAccess enabled by default?
Generally it's not a good idea to try and get around the compiler because of what you "know". Certainly those times exist (non-null assertions are there for a reason), but in general the reason the compiler is there is to force you to "do your homework" so you don't have to rely on your own fallible understanding of the program's types.
47 replies
TTCTheo's Typesafe Cult
Created by currenthandle on 11/19/2022 in #questions
Why is noUncheckedIndexedAccess enabled by default?
I'm curious to hear how others prefer to handle that conveniently, myself.
47 replies