3 ms·
I wish there was some way to just get react-style data bindings, html generation from JS, and code organization, while still hosting from purely a flask/django
by chis 2y ago
I wish there was some way to just get react-style data bindings, html generation from JS, and code organization, while still hosting from purely a flask/django backend. The traditional split of a flask API and a react frontend consuming it, just feels like overkill.
Plus native JavaScript+html is just so close to a complete solution these days. I don’t miss components at all. I just want better code organization.
- morbicer 2y agoI don't understand the second sentence. As someone developing web apps for over 20 years, components ARE the better code organization.
- fmnxl 2y agoWell there's a cost to that abstraction, e.g. you'd have to pass the context into the component, so every time you need to modify the component's schema/props you'd need to change it twice, both in the parent and the component. You must have seen some huge React components with 20 different props or even more, and you'd need to think about memoizing those props to prevent a re-render, etc etc. I've also been a web dev for over 20 years, and 10 years with React. I'd say that going back to native HTML APIs for handling stateful things like forms and form validation is a breeze, rather than writing components and endless abstractions. It's enough for the vast majority of the time.
- morbicer 2y agoThose are just shitty codebases. I maintain a React app that's over 10 years old, almost milion lines of code and we have zero components with 20 props, no issues with performance or whatnot. I am an oponent of over-abstraction but components are very light abstraction and provide just sensible encapsulation and reusability.
- fmnxl 2y agoShow me this amazing site of yours. With that amount of talent maybe you should go over to Next.js and solve their RSC issues.
- azemetre 2y agoI'm really curious too, the only codebase I've seen that was like their description with react treated different pages/routes as one massive separate component. Not exactly utilizing the benefit of JSX but it's a pattern you might blindly fall into if you only came from a templating background.
- morbicer 2y agoI can't, our app is enterprise SaaS built as SPA. Nextjs is imho garbage. The only reason I can imagine it is so popular is that average React devs are indeed very bad with code organization. If I needed server rendering I would go with Astro + interactive islands.
- fmnxl 2y agoI see, you're talking about a fully client-rendered SPA. I guess you can always count on your users running modern PCs, with fast internet and no SEO needs. Things aren't that nice in the outside world lol.
- joshlemer 2y agoI have found that inertia.js is a great solution, it basically allows you to program in your traditional back end multi-page application, MVC kind of style, but with all the benefits of an SPA. So, you get to skip writing an API and just pass data into a view like in the old days, but the view is a React component (or Vue or Svelte)
- 65 2y agoYou might like Vike (it'd be an Express backend but generally people like Express) https://vike.dev/ https://vike.dev/
- chis 2y agoClaude suggests preact+htm, to get pleasant html generation and react-style imperative state transitions but avoid a build stage. I will give it a shot
- kaedroho 2y agoCheck out https://django-bridge.org/ https://django-bridge.org/ It allows you to use a regular Django backend with views, forms, urls, etc but render the UI with Javascript