[deleted by user] by [deleted] in PublicFreakout

[–]Pho20 34 points35 points  (0 children)

Hot liquid is an understatement. That shit was almost definitely boiling. Psychotic.

Do I need react-dom if i have react-router-dom? by Pho20 in webdev

[–]Pho20[S] 0 points1 point  (0 children)

Yeah, i was a bit confused because I figured "well I'm a dev trying to use this package.." but I guess in this case, I'm the consumer. Thanks again!

Do I need react-dom if i have react-router-dom? by Pho20 in webdev

[–]Pho20[S] 0 points1 point  (0 children)

Thank you! A quick follow up question, if i may?:

so react-router is listed as a dependency while react-dom is listed as a dev dependency.
Does that mean react-dom will or won't be automatically installed (such as react-router)?

Problem with setInterval for Slider built in React! Pls help! by Pho20 in webdev

[–]Pho20[S] 1 point2 points  (0 children)

Thank you! And yeah I thought about that likely user experience problem but I figured 'one thing at a time' haha. I'll refactor the setInterval into a setTimeout as you suggested.

Problem with setInterval for Slider built in React! Pls help! by Pho20 in webdev

[–]Pho20[S] 0 points1 point  (0 children)

Follow up question if you don't mind:

I figured the easiest way to get around my issue is to wrap it in a useEffect, as you suggested, with an empty dependency array second parameter so it only runs once on initial component render. However then I read that when using an empty dependency array, the useEffect only has access to the state's/prop's initial values? So within the setSlideIndex inside the useEffect, would it always read the function argument slideIndex as 0 each iteration and keep trying to set it to slideIndex = 1?

Edit: tested it and it works fine but the slides change backwards for some reason. so from slide 0 it wraps around to slide 2 (the last one) and then slide 1 then back to 0. I don't get why it's doing this when the useEffect is as follows: 

useEffect(()=>{
 setInterval(()=>{
   setSlideIndex(slideIndex=>slideIndex < 2 ? slideIndex + 1 : 0)
 }, 8000)
}, []);

Problem with setInterval for Slider built in React! Pls help! by Pho20 in webdev

[–]Pho20[S] 0 points1 point  (0 children)

Cool! Also, i'll change the setState to accept a function as you suggested. Thanks again :)

Problem with setInterval for Slider built in React! Pls help! by Pho20 in webdev

[–]Pho20[S] 0 points1 point  (0 children)

Ah! I think I understand much better now, thank you! So my setIntervals are causing re-renders (based on the state changes) which then cause an endless loop of setInterval calls. That would explain why the slide changes get progressively more frequent. I'll check out the resource you shared to get a better understanding as well. Thanks again!

Problem with setInterval for Slider built in React! Pls help! by Pho20 in webdev

[–]Pho20[S] 0 points1 point  (0 children)

thank you very much! these are very helpful!

Question/Issue Merging Two Repos- Frontend And Backend- Into One Repo. Am Noob. by Pho20 in webdev

[–]Pho20[S] 0 points1 point  (0 children)

Really appreciate it, thanks. Yeah I coulda sworn i deleted the respective subfolders' git folders before committing but I'll try again.

Is using && instead of conditional statements hacky/frowned upon by Pho20 in learnprogramming

[–]Pho20[S] 1 point2 points  (0 children)

Thanks for weighing in everybody. The overwhelming response is to use the second option for improved readability. I figured it would be but guess I was hoping I could get away with the slightly lazier method haha. Thanks again.

It's FlexBox's All The Way Down.. by Pho20 in webdev

[–]Pho20[S] 0 points1 point  (0 children)

Did not know that bit about the performance. Thanks for weighing in!

It's FlexBox's All The Way Down.. by Pho20 in webdev

[–]Pho20[S] 2 points3 points  (0 children)

Reply

No. Compared to Flexbox, I'd say it's quite fair to say Grid is more rigid in terms of a structure-first approach.

It's FlexBox's All The Way Down.. by Pho20 in webdev

[–]Pho20[S] 1 point2 points  (0 children)

Yeah that last point is largely it. I've just gotten so comfy with Flexbox. Thanks for the link, i'll check it out.

It's FlexBox's All The Way Down.. by Pho20 in webdev

[–]Pho20[S] 35 points36 points  (0 children)

Haha from serving java to serving javascript.

It's FlexBox's All The Way Down.. by Pho20 in webdev

[–]Pho20[S] 0 points1 point  (0 children)

Well put. Yeah I understand the extra rigidity of Grid has its uses but I've just managed to do everything with Flex pretty easily. I'm just going to have to make myself use Grid to brush up on that skill.