|
Lumpy posted:Has anyone used launchdarkly for A/B testing, feature gating, etc. If so, any thoughts and opinions? I've used it at two companies. Loved it both times.
|
# ? Dec 8, 2023 02:57 |
|
|
# ? Jun 3, 2024 09:56 |
|
Same. I liked it, and I think it’s great when used as designed.
|
# ? Dec 8, 2023 03:52 |
|
A custom React hook always calls another hook (like useState, useEffect, etc)? And otherwise it's just a function?
|
# ? Dec 12, 2023 09:03 |
|
uncle blog posted:A custom React hook always calls another hook (like useState, useEffect, etc)? And otherwise it's just a function? yup
|
# ? Dec 12, 2023 09:13 |
|
Cool. Is there somewhere this is explicitly stated? https://react.dev/learn/reusing-logic-with-custom-hooks is a bit vague on the topic.
|
# ? Dec 12, 2023 09:27 |
|
They don't have to, you can make a custom hook that doesn't use other hooks if you really want to. There's just no reason to do that.
|
# ? Dec 12, 2023 16:55 |
|
uncle blog posted:A custom React hook always calls another hook (like useState, useEffect, etc)? And otherwise it's just a function? As prom candy said, that is not true. What makes a hook a hook is that it starts with "use".
|
# ? Dec 12, 2023 21:17 |
|
Hmm OK, can you show me an example of a hook that doesn't use any of React's hooks?
|
# ? Dec 13, 2023 08:19 |
|
hey mom its 420 posted:Hmm OK, can you show me an example of a hook that doesn't use any of React's hooks? click on any of the ones here: https://usehooks.com/
|
# ? Dec 13, 2023 08:48 |
|
teen phone cutie posted:click on any of the ones here: https://usehooks.com/ Those pretty much all use react hooks https://github.com/uidotdev/usehooks/blob/main/index.js
|
# ? Dec 13, 2023 15:43 |
|
hey mom its 420 posted:Hmm OK, can you show me an example of a hook that doesn't use any of React's hooks? I would, because a junior developer wrote one like a year ago in our app, but when I came across it, I converted it into a plain old function export and told them why they shouldn't have made it a hook.
|
# ? Dec 13, 2023 15:53 |
|
Lumpy posted:As prom candy said, that is not true. this is hilariously pedantic but i'll bite the following things are all true: * A hook, by convention, starts with `use` * React itself does not treat functions that start with `use` in any special way*; they're just functions. If you define `const useHelloWorld = () => 'hello world'` and call `useHelloWorld()` inside your React component, that's not a hook, that's just a function starting with `use` * What makes a function a hook is that it's either a built-in hook or a custom hook that wraps a built-in hook. the closest thing you'll find to a definition of a hook in react's docs is that they are functions that allow functional components access to react's features (state, context, lifecycle, suspense, etc) * i have not kept up with react 18/suspense so apologies if this has changed lol Lumpy posted:I would, because a junior developer wrote one like a year ago in our app, but when I came across it, I converted it into a plain old function export and told them why they shouldn't have made it a hook. this is a function! your junior developer just wrote a function and prefixed with `use` inaccurately, it is not a hook lol
|
# ? Dec 13, 2023 16:10 |
|
abraham linksys posted:this is hilariously pedantic but i'll bite It is completely pedantic, which I was attempting to point out, but I guess failed to do so appropriately. The React Docs posted:Hook names must start with use followed by a capital letter, like useState (built-in) or useOnlineStatus (custom, like earlier on the page). Hooks may return arbitrary values. Note the bolded part. Hooks do not have to contain calls to other hooks to "be hooks". I can't think of any reason you'd ever do that, but you could. If you do this: JavaScript code:
|
# ? Dec 13, 2023 17:04 |
|
Happy to discover I'm not the only freak that uses `lol` and `lmao` in place of `foo` and `bar`.
|
# ? Dec 13, 2023 17:39 |
|
hey mom its 420 posted:Hmm OK, can you show me an example of a hook that doesn't use any of React's hooks? code:
|
# ? Dec 13, 2023 18:00 |
|
The react-hooks eslint plugin does a naive check for the function's name because it's a lot more reasonable than actually checking the implementation of the body of the function, not because any function named "use" is a hook. The class of errors that lint rule is intended to guard against only occurs when using react's builtin hooks. If your function doesn't use hooks, nothing will break if you conditionally call it or change the order in which its called within a render function. What determines if a function a hook is whether or not it "hooks into" the React rendering lifecycle - and the only way to do that is with React's builtin hooks (or I guess a class component) If you're naming a function "use____" and it's not calling any hooks, then you're misrepresenting what that function does and are going to create confusion for anyone who tries to consume it. Ima Computer fucked around with this message at 18:14 on Dec 13, 2023 |
# ? Dec 13, 2023 18:11 |
|
Ima Computer posted:The react-hooks eslint plugin does a naive check for the function's name because it's a lot more reasonable than actually checking the implementation of the body of the function, not because any function named "use" is a hook. I agree with this 100%. "What is a hook" is simply a convention, and that is silly, but it is what it is.
|
# ? Dec 13, 2023 18:24 |
|
fsif posted:Happy to discover I'm not the only freak that uses `lol` and `lmao` in place of `foo` and `bar`. I use derp, herp, flerp and nerp; code:
|
# ? Dec 13, 2023 18:37 |
|
Ima Computer posted:If you're naming a function "use____" and it's not calling any hooks, then you're misrepresenting what that function does and are going to create confusion for anyone who tries to consume it. 100%
|
# ? Dec 13, 2023 19:46 |
|
Vue 3 for my project and here's basically App.vue surely this is not the best way to load a session into the store before rendering.code:
code:
|
# ? Dec 14, 2023 20:14 |
|
Nolgthorn posted:Vue 3 for my project and here's basically App.vue surely this is not the best way to load a session into the store before rendering. I would make load() a function of the userStore itself, but even if you don’t, call it in a lifecycle hook like onBeforeMount code:
|
# ? Dec 15, 2023 09:59 |
|
Full Circle posted:Those pretty much all use react hooks https://github.com/uidotdev/usehooks/blob/main/index.js oh dam i did not read that post correctly
|
# ? Dec 15, 2023 18:29 |
|
HaB posted:I would make load() a function of the userStore itself, but even if you don’t, call it in a lifecycle hook like onBeforeMount Ok. Using onBeforeMount is a good idea. I am making use of the router's beforeEach hook, unfortunately the beforeEach hook is running before the onBeforeMount finishes, so even though the session is loaded the user is already redirected to the login page. TypeScript code:
code:
TypeScript code:
Nolgthorn fucked around with this message at 06:12 on Dec 18, 2023 |
# ? Dec 18, 2023 06:07 |
|
It seems beforeResolve was the hook I'm looking for.TypeScript code:
|
# ? Dec 18, 2023 18:44 |
|
Trying out solidjs for a small project. People bitch about React all the time, but I'm finding solid fiddlier from a typescript perspective, particularly around conditional rendering. Here's a snippet where some stuff is rendered if a signal called lesson is defined: code:
There's also the annoyance of not being able to destructure reactive props in components without an extra plugin. Currently not really seeing the benefits over ol' React, though maybe it's more apparent from a performance perspective. For small projects I'm much more inclined to value ease of use. I thought about using Svelte for this as well, but I'm a weirdo who actually likes JSX. e: I just realised I misread the docs and I don't need to use their <Show> component - a simple condition should work, although I'd still have the same problem of needing to evaluate the result of the signal. Chas McGill fucked around with this message at 18:55 on Dec 18, 2023 |
# ? Dec 18, 2023 18:48 |
|
What are peoples thoughts on HTMX? Getting flooded on it from the algo, but as someone without frontend experience and wants to avoid JS or JS frameworks, I really like some of the concepts around HATEOAS, hypermedia and declarative use of HTML/CSS. I'm primarily a python guy doing data analysis who secretly loves UI and front end, but everytime I start looking at the front-end JS spaghetti world I get this feeling in the pit of my stomach where I just want to crawl back into the dirt simple python world. Other than job/career dev (ie learning popular frameworks), is there any other aspects of the whole HTMX thing that make folks who do this professionally cringe or thinking "it's a bad idea op"? It just seems like there's a ton of deadass simple use cases where bootstrap, HTMX and flask would make a solid choice on a stack but I also am worried about creating future debt that a real frontend dev would have to maintain.
|
# ? Dec 19, 2023 13:37 |
|
My impression of htmx is that it's a sort of jQuery competitor that forces you to learn a million different html attributes instead of letting you write the code that you really need yourself. It feels like something trendy to me. I don't really appreciate it or understand it. I thought web components would take off more than they did. Since web components didn't take off I'm pretty suspicious htmx definitely won't.
|
# ? Dec 19, 2023 13:58 |
|
Oysters Autobio posted:What are peoples thoughts on HTMX? Getting flooded on it from the algo, but as someone without frontend experience and wants to avoid JS or JS frameworks, I really like some of the concepts around HATEOAS, hypermedia and declarative use of HTML/CSS. htmx, like most web technologies, sounds like something i could come up with as a joke in a bar. ( i have designed components for software products used by millions of users as a joke in a bar.) this also might be a boomer take but i wouldn't pick a library that doesn't have a wikipedia page as something i'd design a product around for work. i'm sure it's fine if you're just playing around though, people can get almost anything to work on the front end.
|
# ? Dec 19, 2023 16:49 |
|
HTMX feels like CSS utility classes in that they both seem like they were designed by people who have a paralyzing fear of doing anything outside of markup. Me? Open up a javascript file? When building a WEBSITE? No thank you.
|
# ? Dec 19, 2023 18:00 |
|
HTMX seems fine for document-driven sorts of webpages that need some light UI elements,. However, it doesn't do any of the heavy state management and reactivity that modern javascript frameworks offer and will probably get in the way if you end up needing that down the line. That being said, gently caress learning modern javascript frameworks. I had to scratch-build a drop-in shopping cart as a Vue application, and holy gently caress is was that a lot of goddamn layers to learn and evaluate and configure. Just to bitch a bit, I had to:
|
# ? Dec 19, 2023 18:15 |
|
Modern front-end development is a staggering amount of footguns and self-owns that could've been avoided if js devs hadn't rejected the entirety of existing software engineering practices as "too bloated" (ironic considering the bloated mess it has become, of course)
|
# ? Dec 19, 2023 18:25 |
Haystack posted:HTMX seems fine for document-driven sorts of webpages that need some light UI elements,. However, it doesn't do any of the heavy state management and reactivity that modern javascript frameworks offer and will probably get in the way if you end up needing that down the line. I mean, once you do the first four steps you're ready for any modern framework.
|
|
# ? Dec 19, 2023 18:29 |
|
I haven't used it for anything yet, but I really like HTMX. It reminds me of Tailwind, except that instead of colocating styles with your markup templates, it colocates your JS code with your markup templates. Colocation gives you dead code elimination for free, and saves you from the cognitive burden of cross-referencing markup templates and their associated JS glue code. I could see it being used to build sites that are heavily backend-driven, with limited amounts of interactivity and/or complex state management. Basically, any time when a fully-fledged frontend framework would feel like overkill. Like for building internal tooling / reporting / dashboard-y things. Oysters Autobio posted:It just seems like there's a ton of deadass simple use cases where bootstrap, HTMX and flask would make a solid choice on a stack but I also am worried about creating future debt that a real frontend dev would have to maintain. If your use cases are truly simple, then I honestly wouldn't worry about creating technical debt. You won't be able to create a significant-enough mess if you're building simple features. Just don't use bootstrap - use Tailwind with DaisyUI instead
|
# ? Dec 19, 2023 20:22 |
|
We use HTMX in our Django app and it's really great. Because we have a lot of forms which need really simple interactivity like "Only show this form field if this other radio button is selected", and to handle that in Django you need to either: - write some jQuery: ewww, because (a) jQuery, and (b) now that code has to live in the HTML template instead of the where the form is defined in Python. - convert the whole form to React: smashing the walnut with a sledgehammer. - use HTMX: pretty easy, just add a couple of custom CSS attrs and you're away.
|
# ? Dec 19, 2023 23:09 |
|
kedo posted:Me? Open up a javascript file? When building a WEBSITE? No thank you. Unironically yes. This is the sole reason I'm interested in HTMX. I do python and mainly data analysis / data science stuff, there is zero reason for me to touch javascript and I'd rather continue improving my python before jumping over to learn a new language. At the same time though, I actually really love front-end design and UX design, but there's no UI frameworks in Python that seem popular enough to use or get into, whereas HTMX has some sort of following (for now...). I know once I start going deeper into front end stuff that eventually I'll be forced to move over to a JS framework, but it's not my current or immediate career interests so 🤷♀️. Most importantly (and always open for alternatives here) is the entire front end ecosystem is just so goddamn terrifying for an idiot like me who learned to code by copy-pasting python. Every one of my attempts to get into front end dev has faced me with this: Haystack posted:That being said, gently caress learning modern javascript frameworks. I had to scratch-build a drop-in shopping cart as a Vue application, and holy gently caress is was that a lot of goddamn layers to learn and evaluate and configure. Just to bitch a bit, I had to: Sorry, gently caress this. Absolutely no. All of this build system poo poo and webpacks and everythinge else that has been slapped together for front-end is just terrifying to me. Absolute respect for folks who do this for a living, honestly, its impressive, but I'm just too stupid for this. If my workplace was all Gitpod'd and VM'd up with decent infra that set this all up for me, sure, but there's just way too many choices and footguns. I have an arts-degree for gently caress sakes 😭. Ima Computer posted:Just don't use bootstrap - use Tailwind with DaisyUI instead I was comparing bootstrap and tailwind+daisyUI but my understanding is that the latter is more of a framework to let you build your own components, while bootstrap already just has a bunch of default components ready to use just by throwing it into your HTML more or less. I don't want to reinvent the wheel, I'd rather use components and widgets designed by much smarter people than ever create my own. edit: okay I definitely did not read enough into DaisyUI, as it does in fact appear to be a component library. Scratch what I said above, thanks for flagging will definitely check it out. Haystack posted:HTMX seems fine for document-driven sorts of webpages that need some light UI elements,. However, it doesn't do any of the heavy state management and reactivity that modern javascript frameworks offer and will probably get in the way if you end up needing that down the line. Yup absolutely. I'm a data analyst, and I'm looking at it as a way to slap a front-end CRUD on to some legacy SQL databases and existing REST APIs. I don't have real any state management other than a boolean column in a table labelled "iswhatever". Any state I need to manage is in the database like god intended. Oysters Autobio fucked around with this message at 23:17 on Dec 20, 2023 |
# ? Dec 20, 2023 13:16 |
|
So signals in React via @preact/signals-react, that good? Can we expect this kind of stuff to land in React proper eventually? Whenever they actually do another release (lol)?
|
# ? Dec 20, 2023 14:29 |
|
Oysters Autobio posted:Sorry, gently caress this. Absolutely no. All of this build system poo poo and webpacks and everythinge else that has been slapped together for front-end is just terrifying to me. Absolute respect for folks who do this for a living, honestly, its impressive, but I'm just too stupid for this. If my workplace was all Gitpod'd and VM'd up with decent infra that set this all up for me, sure, but there's just way too many choices and footguns. I have an arts-degree for gently caress sakes 😭. I get that, but that is stuff you do once a project and never touch again. Plus with Vite, 95% of that poo poo is done for you, you just pick options on the menu. code:
Don't get me wrong, I have been working in primarily frontend for a over a decade now, and Modern Javascript Development is still pretty poo poo, but it is nowhere near as bad as it was, particularly with regard to "too many choices and footguns". Still plenty of rope to hang yourself, but I wouldn't say it has any more pitfalls than any other language - python included. The node ecosystem is a lot less Wild West-y as it used to be, and as long as you stick to things with an actual track record / developer community, you will be fine. Hadn't heard of HTMX until this very discussion, so I took a look. Ew. Not for me. But hey - it if looks like your jam, go for it. I'm just saying, Javascript is no longer the nightmare it is still purported to be.
|
# ? Dec 20, 2023 14:39 |
|
Oysters Autobio posted:Unironically yes. This is the sole reason I'm interested in HTMX. See, I totally understand this perspective because I am also not always terribly interested in picking up a brand new language/framework for a one-off project, but Javascript is foundational to the web these days. To me HTMX feels a lot like someone said, "I'm a construction worker but I only know how to use hammers. I use hammers to hit things, and I don't want to have to learn how to saw things, or drill things, or glue things, so I made this hammer that can saw and drill and glue. It doesn't do any of them well, and it was a convoluted process to make it and actually required that I shoehorn a saw and drill and glue bottle onto my hammer, but at least now I can (poorly!) saw and drill and glue things by simply whacking them with my hammer!" If you're being inexorably drawn towards front-end dev (escape now!), you don't have to go the full npm/framework route to start. In fact you shouldn't. This is still a perfectly acceptable way to build a simple site: code:
|
# ? Dec 20, 2023 16:20 |
|
kedo posted:See, I totally understand this perspective because I am also not always terribly interested in picking up a brand new language/framework for a one-off project, but Javascript is foundational to the web these days. Eh, I think HTMX is more like "I'm not a construction worker looking to make a commercial build, I just want to build a shed that has functionality but I want to be able to just use simple 4x4s, hammer and nails because I don't need pneumatic drills, lifts, electrical, plumbing etc. that a professional construction worker would need to consider." As much as I "like" front-end dev, thats just an interest but not one I am interested in making a career out of. To create my own internal app or something shouldn't require all these build packs and setups and clunky frameworks, just let me write the logic in a language I know (python) and template out the UI. I know JS is foundational to the web, but HTMX' popularity (even if temporary) probably still shows that there's a market for non-pros that want to dabble in front end work but dont want to learn JS. Other domains seem to really give flexibility and "bring your own tools" except for front end development, but I might be conflating how flexible other domains truly are. Oysters Autobio fucked around with this message at 23:29 on Dec 20, 2023 |
# ? Dec 20, 2023 23:25 |
|
|
# ? Jun 3, 2024 09:56 |
|
I've got a video stored in IndexedDB, split into Blobs. If I pull the video out all at once and merge the blobs together, and play it, everything works fine. If I pull out the video blob by blob, I can play the first blob but none of the other blobs play. I feel like I'm not quite sure the correct question to ask here but my hunch is that there's something to do with the blob's header data only existing on the first blob but not the other blobs. Is that correct?
|
# ? Dec 21, 2023 01:11 |