Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Queen Victorian
Feb 21, 2018

frogbs posted:

Thanks, I think that clarifies things a bit. I'm going to try to find more recently updated tutorials that are more focused on what i'm doing (basically searching within a table). I think I just don't like looking at JSX, everything is co-mingled and my brain just stops because it looks like it shouldn't work.

Yeah the React re-render magic does take some getting used to. I was lucky to grasp it pretty quickly due to already being familiar with D3.

As for JSX, I think a lot of folks need to adjust to it. I found it really gross at first because it was in this not-quite-HTML uncanny valley. What helped me was thinking about it like a template literal (how we used to generate HTML in jQuery components) and also being pretty strict about using it only for display purposes, so mostly inserting child display components and writing HTML structure. I like it much better nowadays (except for the lone hanging closing angle brackets ugh I hate them), but I still don't like it for non-display purposes (I'm looking at you, React Router).




prom candy posted:

I usually use React for that kind of thing, so I'd have <Form.Section /> and <Form.Header />

That lets you do nice stuff like <Form.Section variant="airy" /> (for different styles of sections, ideally defined by a typescript enum so you get autocomplete of valid variants)

Or if later on someone says "hey all our form sections need titles now" you can do <Form.Section title="some title" /> instead of having to now add a .form-section-title global class and remember where in the markup it needs to go to look right. And if you make that title prop mandatory your code won't compile until you go back and add titles to all your sections as per the new requirement.

You could totally still use this approach with separate CSS, I have in the past and it works fine, but for me once you get to this point it makes a lot of sense to co-locate your styling with your markup because they're practically the same thing.

Okay this makes a lot of sense and makes it sound way better and more sensible than the rest of the Internet would have me believe. I think an issue with the Tailwind value proposition (some officially but mostly from the community) is that there's a very lopsided ratio of words spent telling you why the old ways are bad/wrong and how separation of concerns is bs vs why Tailwind is good, what it's good for, and how to properly implement it to take full advantage of what it offers. It honestly sounds pretty fantastic for certain use cases and teams where rapid development/delivery is important and there is a highly componentized frontend architecture, but that message gets kind of buried by panacea/way of the future hype, rhetoric I personally find off-putting, and the community pushing not the best of practices (e.g. @apply abuse over proper componentization like you described).

As for me, I tend not to break down components quite that much. I'm the sole frontend dev/designer/maintainer right now and also have ADHD so having so many small components/props/configurations gets overwhelming. It's easier for me cognitive-load-wise to lean more heavily on semantic markup for basic structural stuff so I can have components organized by functional role and compartmentalize the styling and more minor structural considerations and not worry about them until I go into styling/CSS zen mode. (And that's another reason why I'm really not into inline-esque/utility paradigms - I need my CSS zen time during which I dive into the stylesheets and make everything look perfect and do cathartic cleanup/consolidation/optimization.)

Adbot
ADBOT LOVES YOU

Splinter
Jul 4, 2003
Cowabunga!

frogbs posted:

Thanks, I think that clarifies things a bit. I'm going to try to find more recently updated tutorials that are more focused on what i'm doing (basically searching within a table). I think I just don't like looking at JSX, everything is co-mingled and my brain just stops because it looks like it shouldn't work.

You can keep the JS within the markup as minimal as possible by shifting all handlers, calculations and logic into functions, so your markup section only really has function calls/references or basic variable injection (though you'll still probably need to return JSX Elements from those functions in some cases, e.g. the renderSquare function from that tutorial). Still though, I feel you especially since JS dogma for the longest time was 0 code in the markup (to the point of not even using the native onclick HTML attribute). If you're going to stick with React, you'll probably eventually get used to JSX, but there are other modern frameworks that have less co-mingling (though you in many cases you're still going to have some manner of variable injection, logic and looping in your templates, just using some syntax other than JS).

Is your goal still to build that camera bag volume filtering app?

abraham linksys
Sep 6, 2010

:darksouls:
feel like people don't talk enough about how JSX just turning into function calls under the hood means that React is now (accidentally?) the most TypeScript-friendly view framework you can get

if you want to type check your Vue templates: install a VSCode extension maintained by one overworked underpaid dude who is probably going to ragequit someday leaving a bunch of developers in the lurch, and god help you if you want to type check those templates as part of your build process, you better notice the errors in your editor or that poo poo is gonna make it to production because there's no CLI check available

if you want to type check React: well the JSX transform is built into TypeScript because it took like 3 seconds to add to their compiler because it's just turning XML into function calls, and function calls are easy to type, so install the officially-maintained React typings and you are all set

there are lots of things i like about Vue and Vue 3 is more TypeScript-friendly than ever, but JSX is just so ruthlessly efficient with this stuff it's hard to not be jealous

go play outside Skyler
Nov 7, 2005


There is nothing magic about React and JSX. Every time your state changes the JSX is re-rendered. React has no idea what data in your state is linked to which element. The "magic" happens in the diff algorithm that simply looks at the old content and new content and surgically applies changes to the DOM. That's all it is!

ynohtna
Feb 16, 2007

backwoods compatible
Illegal Hen

marumaru posted:

someone has to

I use svelte and I like it.

It's too good to deny it.

Macichne Leainig
Jul 26, 2012

by VG

ynohtna posted:

I use svelte and I like it.

It's too good to deny it.

Unfortunately its goodness has nothing to do with its popularity, especially when it is competing with React, Angular and Vue in the same space.

prom candy
Dec 16, 2005

Only I may dance
React with Typescript is such a pleasant experience and it makes me want to use Typescript for everything. I've been using Swift a lot lately, which is also really nice but man Typescript has some handy features.

Edit: I would like to try Svelte but yeah I'm just not gonna sink my time into learning something that doesn't seem to be taking off.

marumaru
May 20, 2013



Queen Victorian posted:

What helped me was thinking about it like a template literal (how we used to generate HTML in jQuery components) and also being pretty strict about using it only for display purposes, so mostly inserting child display components and writing HTML structure.

Opinion: if your React code doesn't look like a regular template, you hosed up.
Mixing Javascript* with HTML* in React is gross.
If you need to define it in this file, do it outside the return, ffs.

*i know

marumaru
May 20, 2013



ynohtna posted:

I use svelte and I like it.

It's too good to deny it.

Svelte looks awesome, but I wish I could learn/play with it during work hours. It doesn't seem to be picking up speed. :(
Lots of React Believers thought that Vue wouldn't gain popularity because React was too big, but here we are, yet Svelte is still tiny.

prom candy
Dec 16, 2005

Only I may dance

marumaru posted:

Lots of React Believers thought that Vue wouldn't gain popularity because React was too big, but here we are, yet Svelte is still tiny.

I think the existence of Vue might be what's stopping Svelte from growing. There are a lot of people who take one look at React and say "no way, gently caress that" and now those people have Vue.

fsif
Jul 18, 2003

I loved JSX from the jump. What I hated most was all the class boilerplate and welp.

prom candy
Dec 16, 2005

Only I may dance

fsif posted:

I loved JSX from the jump. What I hated most was all the class boilerplate and welp.

Same, I had nothing but issues every time I tried those logic-less templates and javascript frameworks that wanted to shunt every little thing into three different files (looking at you, Ember).

frogbs
May 5, 2004
Well well well

Splinter posted:

You can keep the JS within the markup as minimal as possible by shifting all handlers, calculations and logic into functions, so your markup section only really has function calls/references or basic variable injection (though you'll still probably need to return JSX Elements from those functions in some cases, e.g. the renderSquare function from that tutorial). Still though, I feel you especially since JS dogma for the longest time was 0 code in the markup (to the point of not even using the native onclick HTML attribute). If you're going to stick with React, you'll probably eventually get used to JSX, but there are other modern frameworks that have less co-mingling (though you in many cases you're still going to have some manner of variable injection, logic and looping in your templates, just using some syntax other than JS).

Is your goal still to build that camera bag volume filtering app?

Yeah, that seems like a pretty good first project so that's still my goal. I'm going to look at Vue next I think, just to see how that feels.

VagueRant
May 24, 2012
Anyone have any tips for messing with Google's dataLayer? I feel like I keep getting really inconsistent results adding events through dataLayer for Tag Manger and Analytics, where I set an event in JS, then set a Trigger and a Tag in GTM then set a goal in Google Analytics. Like half of my form submissions aren't captured and a bunch of onclicks aren't registered.

Google's UI is TERRIBLE for arranging these things, wondering if there's a design pattern or something I'm missing.

Splinter
Jul 4, 2003
Cowabunga!

frogbs posted:

Yeah, that seems like a pretty good first project so that's still my goal. I'm going to look at Vue next I think, just to see how that feels.

Yeah I think that is a good first project and relatively straight forward. Your state is just your W, H, D, which are updated via the onChange event from their corresponding inputs (and are probably initialized to 0, so you're volume stays 0 until the user has entered a value for all 3). You also have your constant array of bag data.

Finally you have your display of bags (which maybe is just a simple list w/ each bag as a <li>, or maybe you have a lot of data for each bag and want to pass it to a Bag component to handle a more complex Bag representation). To get the display of bags, you'll map() your bag array to some JSX markup, e.g. bags.map(bag => <li>{bag.name}</li>) or if you have a separate Bag component bags.map(bag => <Bag data={bag} />). At this point, you're going to be always showing all the bags, so the final step for bag display is to first filter you bag array down to only bags that have a volume larger than your current state's volume prior to mapping the bags to display markup, e.g. bags.filter(bag => bag.volume >= w * h * d).map(bag => <Bag data={bag} />). Now, whenever your w, h or d state is updated, React will re-run the bag array filter and mapping with the new volume, automatically showing the new set of bags based on the new volume.

It should ultimately be a pretty small amount of code that implements the functionality you describe. Implementing the same small project in multiple frameworks would be a good exercise to figure out what you like most.

Jimlit
Jun 30, 2005



VagueRant posted:

Anyone have any tips for messing with Google's dataLayer? I feel like I keep getting really inconsistent results adding events through dataLayer for Tag Manger and Analytics, where I set an event in JS, then set a Trigger and a Tag in GTM then set a goal in Google Analytics. Like half of my form submissions aren't captured and a bunch of onclicks aren't registered.

Google's UI is TERRIBLE for arranging these things, wondering if there's a design pattern or something I'm missing.

Do you have an example of how your events are set up? There are a million ways to screw yourself over with GTM / dataLayer stuff.

Macichne Leainig
Jul 26, 2012

by VG
Man, I had no idea that WebGL and WebAssembly actually used GPU acceleration. I thought poo poo like TensorFlow.js would run entirely on the CPU. I have recently learned that I'm wrong about that, and having GPU-accelerated ML models in the browser is actually really freaking cool! Especially because I'm starting to move into aarch64 development and not having to rebuild everything into aarch64 binaries is certainly valuable to me.

Also, a precursory apology for inadvertently contributing to the web-everything of today is probably in order...

Macichne Leainig fucked around with this message at 18:55 on May 21, 2021

MrMoo
Sep 14, 2000

It’s rather limited support though, hopefully the WebGPU end does better.

(edit) Just checking the the tensorflow github, and they're pushing everything. WebAssembly only just landed SIMD support on the CPU, but the team seem to be pushing WebGPU quite hard as well. In so much that GPU computation is getting the attention over actual rendering support.

MrMoo fucked around with this message at 18:59 on May 26, 2021

ModeSix
Mar 14, 2009

Man what is up with the forums posters the last couple of days, several of my regular reading threads (this one included) have lots of crabby joes snipping at each other, is the lack of GPU's on the market and the crypto crash making everyone testy?

On the topic of CSS, I agree that having a framework to build from really simplifies things until you get into specifics when building, definitely makes the prototyping and initial design phase super quick compared to hand rolling everything.

I've used both Bootstrap and Foundation, and I like the default visual styling of Foundation over Bootstrap, but I like the Bootstrap helpers over Foundation any day. I'd like to have Bootstraps ease of use combined with the visual defaults of Foundation. Does that exist?

ModeSix fucked around with this message at 02:52 on May 22, 2021

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

ModeSix posted:

Man what is up with the forums posters the last couple of days, several of my regular reading threads (this one included) have lots of crabby joes snipping at each other, is the lack of GPU's on the market and the crypto crash making everyone testy?



Sunspots or something? Now that you mention it, some normally very chill threads have gotten feisty over the last few days.

On topic: The problem / issue with frameworks is that they try to cover all the bases for everyone, and that involves making choices that either make them very, very verbose, or very, very hard to use outside of their prescribed functions. Sometimes this is worth it, sometimes it is not. I generally find it is not, but I don't pretend my use-cases are everyone else's.

prom candy
Dec 16, 2005

Only I may dance

ModeSix posted:

Man what is up with the forums posters the last couple of days, several of my regular reading threads (this one included) have lots of crabby joes snipping at each other, is the lack of GPU's on the market and the crypto crash making everyone testy?

I thought this thread stayed pretty civil given that everyone who uses different tools than me is wrong.

Empress Brosephine
Mar 31, 2012

by Jeffrey of YOSPOS
I dunno but elsewhere but new Hampshire has been miserably hot so .have jgs the heat

gbut
Mar 28, 2008

😤I put the UN🇺🇳 in 🎊FUN🎉


Sir, I think you're having a strokejs

prom candy
Dec 16, 2005

Only I may dance

gbut posted:

Sir, I think you're having a strokejs

It's only a stroke it it's an SVG, otherwise it's a border

Queen Victorian
Feb 21, 2018

ModeSix posted:

Man what is up with the forums posters the last couple of days, several of my regular reading threads (this one included) have lots of crabby joes snipping at each other, is the lack of GPU's on the market and the crypto crash making everyone testy?

Lol probably my fault - I'd taken a day off work because the covid vaccine hosed me up and probably should have taken a couple days off from posting too.

fsif
Jul 18, 2003

Felt like the discussion was all civil and unusually informative, especially considering what a powder keg Tailwind discussion is on most corners of the Internet.

Macichne Leainig
Jul 26, 2012

by VG

fsif posted:

Felt like the discussion was all civil and unusually informative, especially considering what a powder keg Tailwind discussion is on most corners of the Internet.

To be fair, 99% of discussions around tools like Tailwind are usually people bragging that they're using the coolest bleeding edge tools versus people who are bragging that they're too cool to use the coolest bleeding edge tools, and not a lot of nuance in between. Sure goons can be goony sometimes but especially in the programming threads I find most people usually have their heads on straight.

If you guys were my coworkers I'd hold you guys in a lot less contempt (not a nonzero amount though, let's be realistic).

Macichne Leainig fucked around with this message at 17:56 on May 22, 2021

ModeSix
Mar 14, 2009

Queen Victorian posted:

Lol probably my fault - I'd taken a day off work because the covid vaccine hosed me up and probably should have taken a couple days off from posting too.

I had mine about 3 weeks ago, and I tell you the first 2 or 3 days afterwards I felt like garbo.

Ape Fist
Feb 23, 2007

Nowadays, you can do anything that you want; anal, oral, fisting, but you need to be wearing gloves, condoms, protection.

lunar detritus posted:

Angular is too big and unwieldy for most purposes. Vue is :kiss:

Angular really shines in large webApps tbh. Once you're goodish at it you'd be surprised how little code you end up writing in the end.

dupersaurus
Aug 1, 2012

Futurism was an art movement where dudes were all 'CARS ARE COOL AND THE PAST IS FOR CHUMPS. LET'S DRAW SOME CARS.'
I need to tell the guy at work that wants to switch to Elm that we should switch to angular, and watch his head explode

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

dupersaurus posted:

I need to tell the guy at work that wants to switch to Elm that we should switch to angular, and watch his head explode

He'd be right to.

marumaru
May 20, 2013



there are people who use jQuery with React.

Empress Brosephine
Mar 31, 2012

by Jeffrey of YOSPOS
Could one mix php and react?

marumaru
May 20, 2013



Empress Brosephine posted:

Could one mix php and react?

We do. unfortunately

I find that the PHP folks prefer to use Vue, though. To be fair it seems to be a better fit for the whole "progressive enhancement" thing.

gbut
Mar 28, 2008

😤I put the UN🇺🇳 in 🎊FUN🎉


Laravel opts for Vue for the front end, but we use react with it because we are... different.

You can basically use whatever, the stream don't really cross.

prom candy
Dec 16, 2005

Only I may dance

Empress Brosephine posted:

Could one mix php and react?

You can add react to server-rendered templates yeah. I got my start with React adding it to Rails views but it didn't take long until I wanted to use it for everything

canoshiz
Nov 6, 2005

THANK GOD FOR THE SMOKE MACHINE!

Empress Brosephine posted:

Could one mix php and react?

Works for Facebook and Slack, I guess.

smackfu
Jun 7, 2004

We used to have a Spring Boot + Angular app, where the main html file was a template that Spring Boot injected the CSRF token into. That was kind of neat.

IAmKale
Jun 7, 2007

やらないか

Fun Shoe

marumaru posted:

there are people who use jQuery with React.
jQuery is used here to mount React root "when the page is ready":

JavaScript code:
$(() => {
    const loginParentEl = document.getElementById('login-parent');
    const customBackground = loginParentEl.getAttribute('data-custom-background');
    const customAccentColor = loginParentEl.getAttribute('data-custom-accent-color');

    ReactDOM.render(
        <Login
            customBackgroundUrl={customBackground}
            customAccentColor={customAccentColor}
        />;
        loginParentEl
    );
});
It's not a bad pattern to follow, but you better believe I'm pushing back on any PR that includes this for future pages since there's nothing preventing us from rendering from a script tag just before the ending body tag :toughguy:

Adbot
ADBOT LOVES YOU

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself

marumaru posted:

there are people who use jQuery with React.

one of my very first SO questions was about how to do this when I was first learning React.

And then obviously someone told me I was a dumb idiot

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply