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
Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

necrotic posted:

No semicolons alone is enough to throw that out. “Just memorize all the stupid automatic semicolon insertion rules~” no I’ll just tell it what I intend by using semicolons.

:same:

Adbot
ADBOT LOVES YOU

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Nolgthorn posted:

Does this count as jsx? Could do a full json version of it would be easier to read.

JavaScript code:
function ele (name, attrs, ...children) {
    const element = document.createElement(name);
    for (const [key, value] of Object.entries(attributes)) {
        element.setAttribute(key, value);
    }
    for (const child of children) {
        if (typeof child === 'string') {
            element.appendChild(document.createTextNode(child));
        } else {
            element.appendChild(child);
        }
    }
    return element;
}

ele('div', { class: 'cat' },
    ele('div', { class: 'name' }, 'I\'m a cat'),
    ele('div', { class: 'avatar' },
        ele('img', { src: 'https://blahblah' })
    )
);

JSX is when you write a transpiler that turns this:

code:
<div className="cat">
  <div className="name">I'm a cat</div>
  <div className="avatar"><img src="https://blahblah" /></div>
</div>
into exactly the code you wrote.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice
Keep data / state as close to where it is used as possible

Ex: If I have an app with four sections and one of them is TODOs, and the other three sections don't do anything with ToDos, then only the top-level TODO component knows anything about them, and I keep that state there. Or lower if possible! My app does have authentication though, so all my sections need to know about the User object (just as an example, they may not!) So I will probably create a UserContext, and expose a hook called useUserData or something like that so any component in the app can get that.

EDIT: and you can make your "TODO Knowing Code" a hook as well and just expose the bits you want to your top-level TODO component.

Lumpy fucked around with this message at 21:00 on Feb 23, 2023

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

:emptyquote:

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice
CJS vs ESM: Because being a developer wasn't enough of a pain in the rear end.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

necrotic posted:

Ban time zones and ship it. Easy


prom candy posted:

I am willing to eat dinner at 11pm and go to bed at 5am if it means no more time zones. Hell that's what the Spanish do already.

:same:

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice
JavaScript code:
return record?.querySelector('.product-mark')?.innerText ?? null;
\/\/ Oh duh, I did not answer the actual question.

Lumpy fucked around with this message at 23:45 on Nov 5, 2023

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Roadie posted:

I really want some kind of final Temporal implementation I can use without dragging in like 40kb of unoptimized extra stuff.

Meh, on the front end you just compress the giant background image marketing _has_ to have on the login screen by an extra 1% and you save the file size of Luxon in your bundle.

Adbot
ADBOT LOVES YOU

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

roomforthetuna posted:

But that's how marketing excuses their giant image, because if you just compress the humungous machine learning model that the telemetrics team wants in there you save the file size of their giant image. Where will it end?!

I mean, if we keep doing it, eventually nobody will have to download anything, right?

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