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
Ima Computer
Oct 28, 2007

Stop all the downloading!

Help computer.

worms butthole guy posted:

What's the best SFTP / FTP client for Windows? Mac user for many years going to Windows now

WinSCP. FileZilla is fine too.

Adbot
ADBOT LOVES YOU

worms butthole guy
Jan 29, 2021

by Fluffdaddy
Sweet thanks all

The Merkinman
Apr 22, 2007

I sell only quality merkins. What is a merkin you ask? Why, it's a wig for your genitals!
I'm moving from one giant CSS file (compiled from multiple SCSS files), to a styled component approach.

When doing that, how do you handle the use case of a third party injecting content that you want to match other components?

E.g. it is injecting a <button>, but not using the <button-component> that was made that has all of the styling

neurotech
Apr 22, 2004

Deep in my dreams and I still hear her callin'
If you're alone, I'll come home.

The Merkinman posted:

I'm moving from one giant CSS file (compiled from multiple SCSS files), to a styled component approach.

When doing that, how do you handle the use case of a third party injecting content that you want to match other components?

E.g. it is injecting a <button>, but not using the <button-component> that was made that has all of the styling

Does said <button> have a way it can be targeted by CSS (i.e. an ID)? If so, you use createGlobalStyle to add a global class that targets the button.

https://styled-components.com/docs/api#createglobalstyle

HaB
Jan 5, 2001

What are the odds?

Everyone posted:

:words: about webhosts

Thanks, y'all. Giving DO a look.

The Merkinman
Apr 22, 2007

I sell only quality merkins. What is a merkin you ask? Why, it's a wig for your genitals!

neurotech posted:

Does said <button> have a way it can be targeted by CSS (i.e. an ID)? If so, you use createGlobalStyle to add a global class that targets the button.

https://styled-components.com/docs/api#createglobalstyle

Oh... shoot I forgot "styled components" was a specific API and not just a general thing. This particular case is in Angular, but I'm sure it could come up in Vue as well.

Sistergodiva
Jan 3, 2006

I'm like you,
I have no shame.

The Merkinman posted:

Oh... shoot I forgot "styled components" was a specific API and not just a general thing. This particular case is in Angular, but I'm sure it could come up in Vue as well.

I just wrap any library thing I can't access in a styled component and style the internals using selectors. Is hacky but works for me for customizing our company provided components.

worms butthole guy
Jan 29, 2021

by Fluffdaddy
Hi goons I got a simple question :v

i have a react state that I use to set some HTML to be rendered. One thing I can't figure out is how to insert a variable into the string that is already a ternary expression, if that makes sense. I mean I know i could do this with a function call but was hoping it was possible in-line. Is this possible?

Here's what i have

code:
      setPinHtml(`
                                    <div class="fractionalDiv">
                                        ${pinInfo.pin_image ? <img src={pinInfo.pin_image.src} alt={pinInfo.pin_image.alt}/> : null}
			</div>
				

so the ternary runs but it won't properly set the image source to that variable. I tried doing a inline like ${pinInfo.pin_image.src} but that gives me a compiling error. Any ideas?

Thanks!

prom candy
Dec 16, 2005

Only I may dance

worms butthole guy posted:

Hi goons I got a simple question :v

i have a react state that I use to set some HTML to be rendered. One thing I can't figure out is how to insert a variable into the string that is already a ternary expression, if that makes sense. I mean I know i could do this with a function call but was hoping it was possible in-line. Is this possible?

Here's what i have

code:
      setPinHtml(`
                                    <div class="fractionalDiv">
                                        ${pinInfo.pin_image ? <img src={pinInfo.pin_image.src} alt={pinInfo.pin_image.alt}/> : null}
			</div>
				

so the ternary runs but it won't properly set the image source to that variable. I tried doing a inline like ${pinInfo.pin_image.src} but that gives me a compiling error. Any ideas?

Thanks!

I think it could be related to this happening inside a string in that setPinHtml(``) function call. So because it's in a string I don't think you can just use JSX. I think you might want something like:

code:
setPinHtml(`
  <div class="fractionalDiv">
    ${pinInfo.pin_image
      ? `<img src="${pinInfo.pin_image.src}" alt="${pinInfo.pin_image.alt}" />` 
      : ''}
  </div>
`)
Alternately:

code:
const pinImgTag = pinInfo.pin_image 
  ? `<img src="${pinInfo.pin_image.src}" alt="${pinInfo.pin_image.alt}" />` 
  : '';
setPinHtml(`<div class="fractionalDiv">${pinImgTag}</div>`)

worms butthole guy
Jan 29, 2021

by Fluffdaddy
Sweeeet thanks prom candy that worked

prom candy
Dec 16, 2005

Only I may dance
No problem. There may also be a way to actually write out what you want as JSX and then use like ReactDOM.renderToString to turn it into HTML. I haven't had to work with a library like this in a long long time so I don't know what the best way of doing that would be these days but here's something I found on SO that I think is trying to solve the same problem as you. https://stackoverflow.com/questions/37079847/is-it-ok-to-use-reactdomserver-rendertostring-in-the-browser-in-areas-where-reac

Doing what you're doing is also probably fine if the HTML you're generating isn't overly complex and annoying to work with.

worms butthole guy
Jan 29, 2021

by Fluffdaddy
I ended up using some library, ReactHTMLParser to parse it as actual HTML which seems tow ork perfectly and not have to bother with setDangeorusly. But yeah i'm lucky in that it's very simple HTML

Chenghiz
Feb 14, 2007

WHITE WHALE
HOLY GRAIL
Is there a reason you're exposing yourself to xss attacks by building html strings instead of rendering your html with React, since you already apparently have React?

prom candy
Dec 16, 2005

Only I may dance

Chenghiz posted:

Is there a reason you're exposing yourself to xss attacks by building html strings instead of rendering your html with React, since you already apparently have React?

It looks to me like it's a mapping library that manages the DOM itself

worms butthole guy
Jan 29, 2021

by Fluffdaddy
I know this is a very dude bro centric profession, but i'm getting tired of the people on StackOverflow who spend more time formatting your questions with list formatting than answering the fukkin questions. Is this a recent thing thats happened with the site? I've noticed alot of elitism also lately over there.

I don't doubt it's worth but it can get annoying at times

camoseven
Dec 30, 2005

RODOLPHONE RINGIN'

worms butthole guy posted:

I know this is a very dude bro centric profession, but i'm getting tired of the people on StackOverflow who spend more time formatting your questions with list formatting than answering the fukkin questions. Is this a recent thing thats happened with the site? I've noticed alot of elitism also lately over there.

I don't doubt it's worth but it can get annoying at times

I finally signed up last week and have been answering some questions, but I can't get any rep cause no one ever votes on answers or accepts them. I'll see dudes come through with 500k rep edit the question like you said, but can't even toss me a vote!!!

prom candy
Dec 16, 2005

Only I may dance
StackOverflow is pretty much a read-only site for me, but I do toss votes on obscure answers that solve my problem. If I'm asking a question it's usually on SA or in a Discord somewhere.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

prom candy posted:

StackOverflow is pretty much a read-only site for me, but I do toss votes on obscure answers that solve my problem. If I'm asking a question it's usually on SA or in a Discord somewhere.

I'll use stack overflow if it comes up in a google search, but I don't ask questions or contribute anymore. What seems to have happened is that in the 2010's, some recruiters were pushing stackoverflow activity (along with github contributions, etc) as a heuristic for whether a dev was worth hiring, and this became a cobra effect that drove down the quality of the site significantly.

worms butthole guy
Jan 29, 2021

by Fluffdaddy
What do you folks use instead? I know Discord was mentioned, any good channels?

MrMoo
Sep 14, 2000

camoseven posted:

I finally signed up last week and have been answering some questions, but I can't get any rep cause no one ever votes on answers or accepts them. I'll see dudes come through with 500k rep edit the question like you said, but can't even toss me a vote!!!

I get thousands of votes from olde PHP questions that are super basic, and less then a dozen for anything actually complicated.

teen phone cutie
Jun 18, 2012

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

MrMoo posted:

I get thousands of votes from olde PHP questions that are super basic, and less then a dozen for anything actually complicated.

lol yes this. for a couple weeks there I was getting into answering complicated typescript questions just to test my own knowledge and after basically nobody interacted with my answers, i gave up

camoseven
Dec 30, 2005

RODOLPHONE RINGIN'

teen phone cutie posted:

lol yes this. for a couple weeks there I was getting into answering complicated typescript questions just to test my own knowledge and after basically nobody interacted with my answers, i gave up

This is EXACTLY what I was trying to do and exactly what is happening lol

Armauk
Jun 23, 2021


worms butthole guy posted:

What do you folks use instead?

IRC

zokie
Feb 13, 2006

Out of many, Sweden
Answering questions commits you to the possibility of being wrong and getting down voted. I think that is why you see so many answers in the comments and people farming rep from formatting stuff and other low risk activities.

philihp
Jun 1, 2008

Bruegels Fuckbooks posted:

I'll use stack overflow if it comes up in a google search, but I don't ask questions or contribute anymore. What seems to have happened is that in the 2010's, some recruiters were pushing stackoverflow activity (along with github contributions, etc) as a heuristic for whether a dev was worth hiring, and this became a cobra effect that drove down the quality of the site significantly.

Imagine having to convince a recruiter that you're worth hiring. I'd take a technical interview over that any day.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

philihp posted:

Imagine having to convince a recruiter that you're worth hiring. I'd take a technical interview over that any day.

It was mostly poo poo like: https://softwareengineering.stackexchange.com/questions/20407/will-high-reputation-in-stack-overflow-help-to-get-a-good-job.

Devs used to tell aspiring programmers to do poo poo like contribute to github/stackoverflow etc, and recruiters took those proclamations from the devs, and a legion of unemployable zombies took that to mean that they too could get six figgies tech jobs by changing lowercase to uppercase in documentation on random github repositories if they just did it enough times.

Chenghiz
Feb 14, 2007

WHITE WHALE
HOLY GRAIL

Opulent Ceremony
Feb 22, 2012
Can anyone recommend a good book (or otherwise) to learn about React? This is meant for a team of developers who have been using React (only functional components and hooks) with Typescript for a little less than a year: something intermediate to advanced to improve our understanding, which is decent enough to get work done but occasionally is still snagged by gotchas, plus we don't have a good handle on reasoning about performance when comparing ways of doing something, etc.

prom candy
Dec 16, 2005

Only I may dance
Do people write books anymore? I'm not sure if you'll be able to find the info you need neatly organized in one place. If you have questions though :justpost:, there's a bunch of React devs in this thread.

smackfu
Jun 7, 2004

React moves pretty slow, there is probably time to write books.

fsif
Jul 18, 2003

smackfu posted:

React moves pretty slow, there is probably time to write books.

Ha! Right, this is probably at the core of why it's so hard to find intermediate/advanced resources; anything at that level that begins to approach a canonical resource dies with a few years. I always used to recommend the Dan Ambramov guide to useEffect, but now the React team seems to want to kill useEffect entirely.

To the OP—share anything good you find, but once you get past the React basics, you kind of have to keep up with the meta via some combination of Twitter, YouTube, conference talks, and podcasts.

Opulent Ceremony
Feb 22, 2012

prom candy posted:

Do people write books anymore? I'm not sure if you'll be able to find the info you need neatly organized in one place. If you have questions though :justpost:, there's a bunch of React devs in this thread.

Work wants us to try our hand at some sort of communal in-depth learning activity (1st suggestion was read a book together and discuss the chapters) as an experiment and React seemed like the best subject since it is the most new of our tools to us. If someone has a series of videos or a collection of blog posts I'm down for that too. Fair enough if no one can recommend anything in that vein; in that case I'll probably just compare the table of contents of a few of the books that pop up when you search 'react books 2022' and pick one just so we've got something to try.

Macichne Leainig
Jul 26, 2012

by VG

fsif posted:

I always used to recommend the Dan Ambramov guide to useEffect, but now the React team seems to want to kill useEffect entirely.

Are they replacing it with different hooks entirely or what? First I've ever heard of this :(

prom candy
Dec 16, 2005

Only I may dance

fsif posted:

Ha! Right, this is probably at the core of why it's so hard to find intermediate/advanced resources; anything at that level that begins to approach a canonical resource dies with a few years. I always used to recommend the Dan Ambramov guide to useEffect, but now the React team seems to want to kill useEffect entirely.

Do they? They only thing I've heard recently is about the forthcoming useEvent hook.


Opulent Ceremony posted:

Work wants us to try our hand at some sort of communal in-depth learning activity (1st suggestion was read a book together and discuss the chapters) as an experiment and React seemed like the best subject since it is the most new of our tools to us. If someone has a series of videos or a collection of blog posts I'm down for that too. Fair enough if no one can recommend anything in that vein; in that case I'll probably just compare the table of contents of a few of the books that pop up when you search 'react books 2022' and pick one just so we've got something to try.

At my old work we used to do lunch n learns where we'd pile into the conference room and watch YouTube videos. I'm guessing you're probably remote now but there's still ways to watch stuff together right? Maybe there are books out there, I dunno. I haven't bought a programming book in about ten years since online resources have generally been up to date, mostly free, and they don't take up space in my house. I also personally learn much better from videos than just about any other format.

fsif
Jul 18, 2003

Protocol7 posted:

Are they replacing it with different hooks entirely or what? First I've ever heard of this :(

"Kill useEffect entirely" was hyperbolic/me speculating wildly based on some recent developments. "Steer people away from using it so frequently" is probably a more accurate way of putting it.

As prom candy mentioned, they're looking to introduce a `useEvent` hook to replace a lot of the current `useEffect` implementations. The beta React docs also features a section about using useEffect less. And now in React 18 strict mode, they've been forcing useEffect to run twice, which effectively breaks a lot of common implementations of the hook (like data fetching).

So, you know, the React team has kind of been implying that the community has been using useEffect incorrectly for the past four years or whatever and clearly they've been rethinking the paradigm. My assumption is that they are trying to sunset useEffect's role as one of the "main" hooks and relegate to more edge case-y uses.

Macichne Leainig
Jul 26, 2012

by VG
Hmm. That is interesting and I think we did get burned by that React 18 useEffect thing (our app was React 16 initially and we had an initiative to basically update everything to latest versions for security or w/e).

Being in web dev is so exciting :allears:

smackfu
Jun 7, 2004

I have definitely seen people who don’t know React abuse useEffect. They write code that updates a state variable (from useState), then have a useEffect respond to that state change. Ugh.

fsif
Jul 18, 2003

smackfu posted:

I have definitely seen people who don’t know React abuse useEffect. They write code that updates a state variable (from useState), then have a useEffect respond to that state change. Ugh.

I feel like I "know" React (been using it since the class components days) and I would have thought this was an acceptable use of useEffect until very recently.

It has a dependency array and fires off whenever one of the dependencies changes! Why wouldn't I intuit that I could use is like this?

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.'

fsif posted:

And now in React 18 strict mode, they've been forcing useEffect to run twice

Well that explains something I've been tearing my hair out over!

Adbot
ADBOT LOVES YOU

Potassium Problems
Sep 28, 2001

fsif posted:

"Kill useEffect entirely" was hyperbolic/me speculating wildly based on some recent developments. "Steer people away from using it so frequently" is probably a more accurate way of putting it.

As prom candy mentioned, they're looking to introduce a `useEvent` hook to replace a lot of the current `useEffect` implementations. The beta React docs also features a section about using useEffect less. And now in React 18 strict mode, they've been forcing useEffect to run twice, which effectively breaks a lot of common implementations of the hook (like data fetching).

So, you know, the React team has kind of been implying that the community has been using useEffect incorrectly for the past four years or whatever and clearly they've been rethinking the paradigm. My assumption is that they are trying to sunset useEffect's role as one of the "main" hooks and relegate to more edge case-y uses.

Thanks for this, I just refactored a couple of components in a project to not have useEffect anymore in favor of more efficient methods pointed out in your links

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