Best Practice - Handling undefined deps on custom use hook

Good day everyone! I know this is more of a react specific question, but I spend all day in Nextjs land so I thought I'd pose this question to you all. Been struggling a bit with something. What is everyone's favorite way to handle undefined deps for a useHook?
const useSomething = (someDep: string) => {
... something that requires "someDep" ...
}
const useSomething = (someDep: string) => {
... something that requires "someDep" ...
}
Obviously I can set someDep to be optional and check for it during runtime, but it feels like an anti-pattern given it really is required. Often libs seem to use an "enabled" parameter, but values passed in always fail the type check when they're possibly undefined even though enabled: false if dep is undefined.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server