|
Chenghiz posted:Don't use splice (because it mutates), use filter or slice. doesn't slice remove all elements up to x?
|
# ? Oct 19, 2022 15:38 |
|
|
# ? Jun 9, 2024 21:16 |
|
In your particular case you want filter. In general when you would use splice, use filter or slice instead
|
# ? Oct 19, 2022 15:42 |
|
gotcha okay, thanks! edit: although I guess my question is, can you use filter with the index of a array? that's what i'm passing through, since I theoretically can have items with the same ID #
|
# ? Oct 19, 2022 15:42 |
|
edit; ignore me lmao
worms butthole guy fucked around with this message at 16:07 on Oct 19, 2022 |
# ? Oct 19, 2022 16:03 |
|
This is not at all the question you asked but I'm gonna give you unwanted advice anyway. If these are Redux reducers you should be using Redux Toolkit. Hand-writing your reducers and actions is hell. Redux Toolkit is the officially recommended way to write Redux now and it's way better. It also has immer built in which makes dealing with immutability way easier. https://redux-toolkit.js.org/ You don't have to adopt it all at once but I would stop writing any new new reducers pretty much immediately and start using RTK for those.
|
# ? Oct 19, 2022 16:48 |
|
I guess my question would be what's the benefit of using Redux over handwriting them for a simple use case like this? That's not me being snarky I just kinda like hand writing them as it reminds me of video game state machines. I'm not using Redux though, just the basic functions of React (useContext)
|
# ? Oct 19, 2022 17:07 |
|
worms butthole guy posted:edit: although I guess my question is, can you use filter with the index of a array? that's what i'm passing through, since I theoretically can have items with the same ID # ya. filter takes a callback function that takes the index as the second argument TypeScript code:
teen phone cutie fucked around with this message at 17:18 on Oct 19, 2022 |
# ? Oct 19, 2022 17:12 |
|
teen phone cutie posted:ya. filter takes a callback function that takes the index as the second argument genious.
|
# ? Oct 19, 2022 17:15 |
|
worms butthole guy posted:I guess my question would be what's the benefit of using Redux over handwriting them for a simple use case like this? That's not me being snarky I just kinda like hand writing them as it reminds me of video game state machines. I'm not using Redux though, just the basic functions of React (useContext) I actually use createSlice quite a bit to create reducers for use with useReducer even though it's meant for Redux. I don't use Redux anymore really. I also wouldn't be hand rolling my own global store with useContext either though (if that's what you're doing). It has performance issues if you have a lot of components hooked up to one context. I'm just surprised to see someone hand rolling a reducer, I haven't done that in a long time.
|
# ? Oct 20, 2022 05:59 |
|
I think the redux browser addon makes it worth it alone. But yeah, toolkit all the way.
|
# ? Oct 20, 2022 07:08 |
|
Question and not trying to be a troll but how is redux faster then native react functionality
|
# ? Oct 20, 2022 14:54 |
|
If you aren’t creating a complex app do yourself a massive favor and look into jotai and zustrand. Absolutely perfect state management for simple apps.
|
# ? Oct 20, 2022 15:30 |
|
worms butthole guy posted:Question and not trying to be a troll but how is redux faster then native react functionality first of all, if using useReducer is working for your usecase, by all means use it you don't have to use Redux and it's no faster than using local state, unless you're pairing it with the context API. I'd start thinking about state management libraries if you've got a lot of contexts which contain state and wrap your entire app, because in that case, every child of the context is going to re-render every time the state changes it sounds like you're still very much learning and if this is a personal project, just do what's easiest for you
|
# ? Oct 20, 2022 15:42 |
|
Yeah, and if you live the Redux devtools, you can hook your Zustand store into them.
|
# ? Oct 20, 2022 15:49 |
|
teen phone cutie posted:first of all, if using useReducer is working for your usecase, by all means use it you don't have to use Redux and it's no faster than using local state, unless you're pairing it with the context API. Nah, not neccesarily learning, my job just has me make proof of concepts in several languages and this one poc involved a bunch of moving parts dependant on others in React. Totally interested in looking into state management's if it makes proofs easier to make and faster, I was just confused why a non React library would be faster than React itself. My state management uses the useReducer hook. This for example is what I used for a personal project which is similar to what I used for this proof:
|
# ? Oct 20, 2022 16:12 |
|
Oh also I forgot to say that the system we work in only allows a total package size of 1mb before webpack lol.so it's usually a question of "is this package worth the space"
|
# ? Oct 20, 2022 16:14 |
|
dont use redux its bad
|
# ? Oct 21, 2022 03:28 |
|
Context's performance issues are because you can't subscribe to just part of your context. So say you have a context that provides an object with cats and dogs. If you have a component subscribed to it that only cares about cats it will still re-render even if dogs changes. Redux and other state management tools use techniques for subscription that will only cause re-renders if the specific slice of state you care about changes. There is some new poo poo in react 18 that I think improves the context situation but really if you have a bunch of global state id look at Zustand and Jotai and use the one that feels right to do. Personally I like Zustand. Also if you're mainly just syncing server state literally just use react-query. There's not even a discussion worth having about that at this point, it's by far the best data fetching and caching lib for React.
|
# ? Oct 21, 2022 05:52 |
|
Took a long hiatus from Vue because I needed to make money again for a while, I'm playing around with it again. It looks like it's come a long way, I used to like it a lot and now it's really really good. At least that's my first impression. It installed very quickly, my package.json isn't loaded with tons of garbage. It runs in it's development environment without any noticeable compilation, live updates occurring the ms I save a file. It's great. Vuex seems to have disappeared. There's an alternative one but otherwise the docs lay out everything you might do with a complex state management system without needing one. I'm reading reports that you probably don't want to use Typescript with it which is a bit disappointing but understandable. Looking good.
|
# ? Oct 22, 2022 00:40 |
|
Wrong! Use typescript.
|
# ? Oct 22, 2022 00:44 |
|
I haven't written anything clientside without typescript in a while, I bet I can do it.
|
# ? Oct 22, 2022 00:49 |
Nolgthorn posted:I'm reading reports that you probably don't want to use Typescript with it which is a bit disappointing but understandable. What? Vue 3 is amazing with typescript
|
|
# ? Oct 22, 2022 00:49 |
|
What about the state management, can I write a relatively complex spa without pinia?
|
# ? Oct 22, 2022 00:52 |
|
Nolgthorn posted:I haven't written anything clientside without typescript in a while, I bet I can do it. do you want that on the tombstone in a serif or non-serif font?
|
# ? Oct 22, 2022 00:55 |
|
Spime Wrangler posted:do you want that on the tombstone in a serif or non-serif font? "Tried to write a SPA without Typescript." in gothic bold.
|
# ? Oct 22, 2022 00:57 |
Nolgthorn posted:What about the state management, can I write a relatively complex spa without pinia? Pinia also supports TS with no issues, it's even written in typescript, but ...I guess, sure? I'd use provide/inject as the base, but I think it'd get very messy very fast if you're not careful.
|
|
# ? Oct 22, 2022 00:58 |
|
I was just meaning is pinia necessary or do you recommend it.
|
# ? Oct 22, 2022 01:00 |
|
prom candy posted:Context's performance issues are because you can't subscribe to just part of your context. So say you have a context that provides an object with cats and dogs. If you have a component subscribed to it that only cares about cats it will still re-render even if dogs changes. Redux and other state management tools use techniques for subscription that will only cause re-renders if the specific slice of state you care about changes. You should watch this video! https://www.youtube.com/watch?v=ZKlXqrcBx88
|
# ? Oct 23, 2022 23:38 |
|
Lumpy posted:You should watch this video! Haha yeah that was the "there's some new poo poo in React 18 that improves this" part. I haven't watched the video yet but it's been in my YT recs for a while. I like Jack Herrington but his videos are a bit long for me so I often don't get around to watching them. Is this that useSyncExteralStore stuff or is it something else?
|
# ? Oct 24, 2022 06:17 |
|
prom candy posted:Haha yeah that was the "there's some new poo poo in React 18 that improves this" part. I haven't watched the video yet but it's been in my YT recs for a while. I like Jack Herrington but his videos are a bit long for me so I often don't get around to watching them. Is this that useSyncExteralStore stuff or is it something else? Yeah, apparently after learning just one more thing (useSyncExteralStore) you can eliminate 4 extra lines of code you used to have to write. The convenience is off the charts.
|
# ? Oct 24, 2022 08:22 |
|
Nolgthorn posted:Yeah, apparently after learning just one more thing (useSyncExteralStore) you can eliminate 4 extra lines of code you used to have to write. The convenience is off the charts. It still seems like using one of the many excellent off the shelf state managers would be a better idea, no?
|
# ? Oct 24, 2022 17:15 |
|
Any recommendations for senior front-end engineer interview prep? Or just Senior interview prep in general? I have no problem with the coding challenges I'm getting, and I can talk very well about personal projects, but I feel like I'm supposed to be asking five erudite questions every minute and I can't think of any.
|
# ? Oct 26, 2022 22:49 |
|
https://forums.somethingawful.com/showthread.php?threadid=3845966&perpage=40&noseen=1#post480076891
|
# ? Oct 26, 2022 22:52 |
|
prom candy posted:It still seems like using one of the many excellent off the shelf state managers would be a better idea, no? Sort of something that's confusing me about Vue 3 right now, reading the documentation. The built in component state management has been separated, so you can actually define a state in a separate file and import it in multiple components. At that point it's half way to being a state manager. Makes me wonder what I need Pinia for at all, I'm sure after a bit of experimentation I'll figure it out. Maybe Vue 4 will give up on component state and state management being separate things entirely. It'll just be one clean tree shaken dependency, where I can define little state managers and big state managers to my heart's content. Nolgthorn fucked around with this message at 08:31 on Oct 27, 2022 |
# ? Oct 27, 2022 08:17 |
|
prom candy posted:It still seems like using one of the many excellent off the shelf state managers would be a better idea, no? Did y'all see Next 13? It looks really good. It's like we can finally write JS like we wrote PHP, but in a good way.
|
# ? Oct 28, 2022 08:02 |
|
So I mostly work with HubSpot and at their developer conference they announced SSR React using "Islands" and moving from webpack to Vite. I don't really understand what benefits this brings to HubSpot pages in particular over regular React, since HubSpot has extreme api rate limits (only allowed 4 calls per second across all visitors) and wondering if any of you can think of a use case.
|
# ? Oct 28, 2022 15:42 |
|
hey mom its 420 posted:Did y'all see Next 13? It looks really good. It's like we can finally write JS like we wrote PHP, but in a good way. Yeah Next 13 is pretty cool. I was pretty hot for Remix but I think Next is gonna be the way forward. There's a bunch of stuff that's not yet supported in the new app folder though (i18n for one). Turbopack also seems legit.
|
# ? Oct 28, 2022 21:52 |
|
the data fetching stuff next.js 13 is doing is also going to be a thing Remix starts adopting. it's all just stuff that was held back on react server components + suspense taking an extremely long time to develop (tbf: hard loving problem!), so I think a lot of these SSR frameworks that have focused on per-route loaders are now going to be moving to leaf-based loading next seems ahead of the curve but also did the classic "let's launch our new version whenever we have our next big conference regardless of whether it's ready" thing so every single feature, including the new docs, is marked as "beta," so I look forward to adopting it in like six months. will be nice to replace a lot of gross code I've written to get everything loaded in getServerSideProps with leaf-based data fetching for sure
|
# ? Oct 28, 2022 21:54 |
|
For me, the one big thing still totally missing in Next as compared to Remix is form handling. Not "mutations" or any other fancy poo poo done through frontend JS, just plain form handling that will work right with a form POST from a static page. Remix by comparison got this right from step 1 with "all mutations are just form submissions".
|
# ? Oct 29, 2022 00:04 |
|
|
# ? Jun 9, 2024 21:16 |
|
What’s the best framework for small web UIs,mainly for forms and data tables. I need to have graphql support.
|
# ? Oct 29, 2022 03:19 |