|
This is a long shot, but is there any sensible way to prevent rerendering the entire collection held in the state of React Context when I update part of it? My state looks like this:code:
code:
RobertKerans fucked around with this message at 16:39 on Jan 30, 2019 |
# ? Jan 30, 2019 16:37 |
|
|
# ? Apr 28, 2024 00:05 |
|
MrMoo posted:That's the overhead Browsix is presenting above the WebApis by a browser, which ignores that the apis inherently different concepts. Ok, I was confused because you said "the Browsix shim for testing posix apps in WASM". Browsix isn't actually for testing posix apps in WASM, that's what Browsix-WASM is. Yes it's confusing naming. Anyway, I don't know how well the benchmarks of the posix apis will map on to actual future wasm apps, but I'm also not sure how you can seem so confident that there is no correlation. I guess we'll see.
|
# ? Jan 30, 2019 17:05 |
|
Is a new tech. I am not surprised if really on their first full test they find it dumb slow. You start optimizing when you have a tool to measure, so is normal that before that tool even existed* "peak slowdowns" where hiding somewhere. Also the parity with native code is a dumb goal, but is a cool goal. *tools to test it on non-trivial examples
|
# ? Jan 30, 2019 17:10 |
|
Anyone know how to make Gatsby poo poo out a minimal bundle with a predictable name?
|
# ? Jan 31, 2019 04:26 |
|
Munkeymon posted:Anyone know how to make Gatsby poo poo out a minimal bundle with a predictable name? Ehhh this sounds funky. As in you don't want the chunked, path based bundles? I'd steer clear of doing this, but I'd imagine you can do something to this extent by overriding/adding your own rules to the webpack config: https://www.gatsbyjs.org/docs/add-custom-webpack-config/ Doh004 fucked around with this message at 13:33 on Jan 31, 2019 |
# ? Jan 31, 2019 13:12 |
|
Doh004 posted:Ehhh this sounds funky. As in you don't want the chunked, path based bundles? I'm just using it as a static site generator that happens to use a framework I'm familiar with and it's slightly more annoying to clean up the old files when I copy stuff to the server. Plus I almost certainly won't need, say, the map files because I'm not doing anything complicated, so leaving them out of the build output should be fine.
|
# ? Jan 31, 2019 15:31 |
|
Munkeymon posted:I'm just using it as a static site generator that happens to use a framework I'm familiar with and it's slightly more annoying to clean up the old files when I copy stuff to the server. Plus I almost certainly won't need, say, the map files because I'm not doing anything complicated, so leaving them out of the build output should be fine. If you don't have a tool to handle the diffing for you (I host mine on S3 and use their CLI to sync the folder), couldn't you just clear out the folder entirely and reupload it each time. Obviously depends on the size of your site.
|
# ? Jan 31, 2019 16:29 |
|
Just host it on netlify?
|
# ? Jan 31, 2019 16:48 |
|
Munkeymon posted:I'm just using it as a static site generator that happens to use a framework I'm familiar with and it's slightly more annoying to clean up the old files when I copy stuff to the server. Plus I almost certainly won't need, say, the map files because I'm not doing anything complicated, so leaving them out of the build output should be fine. Use rsync with the --delete option. It is your old file removing friend.
|
# ? Jan 31, 2019 16:58 |
|
Doh004 posted:If you don't have a tool to handle the diffing for you (I host mine on S3 and use their CLI to sync the folder), couldn't you just clear out the folder entirely and reupload it each time. Obviously depends on the size of your site. It's just a cheap VPS I've been using forever, so I SSH/SFTP everything. Boggles my mind that there's no CLI support for that that I can find, though. I guess the world has passed me by. prom candy posted:Just host it on netlify? Guess I might try at some point. Lumpy posted:Use rsync with the --delete option. It is your old file removing friend. Ooh that's what that's good for
|
# ? Jan 31, 2019 17:37 |
|
If you can ssh into the server how do you not have access to the CLI? On most VPSs I’ve used in the past the two are synonymous.
|
# ? Jan 31, 2019 18:31 |
|
kedo posted:If you can ssh into the server how do you not have access to the CLI? On most VPSs I’ve used in the past the two are synonymous. I never said I din't have CLI access - I just can't find where there's a nifty Gatsby plugin that'll just deploy some files over SSH/SFTP and clean up the old ones. At least I assume the S3 plugin doesn't just keep stuffing new files in S3 without removing the old ones.
|
# ? Jan 31, 2019 18:45 |
|
Munkeymon posted:
|
# ? Jan 31, 2019 19:47 |
|
Reading comprehension is apparently not my greatest strength. Time to remove that line from the ol' resume...
|
# ? Jan 31, 2019 20:42 |
|
Are there any great tutorials out there that can turn me into a rock-solid webpack and babel master. I've been writing webpack-built React apps for ~2 years and I can definitely fumble my way through project bootstrapping by doing lots of Googling, but has anyone out there made in-depth comprehensive tutorials on how to bootstrap apps and understand 100% of what you're doing? e: I'm talking about vocabulary, what plugins are, what presets are, the whole nine yards teen phone cutie fucked around with this message at 03:36 on Feb 6, 2019 |
# ? Feb 6, 2019 03:00 |
|
Grump posted:Are there any great tutorials out there that can turn me into a rock-solid webpack and babel master. I had this in my bookmarks, can't recall if I thought it was good or not. https://www.robinwieruch.de/minimal-react-webpack-babel-setup/
|
# ? Feb 6, 2019 03:29 |
e: hang on i'm pretty tired so i'm going to keep working on it, possibly sleep and try again in the morning, because i'm getting all turned around e2: oh man i just lost a solid hour and a half because i didnt realise that the Vuex store you create and reference still has to be called store. like, you can't arbitrarily call it whatever you want that makes sense within your app, it has to be store, and it wasn't just a naming convention for the examples. oh man i'm so sloppy, haha Sulla Faex fucked around with this message at 00:42 on Feb 7, 2019 |
|
# ? Feb 7, 2019 00:03 |
|
Has anyone had to persist indexedDB data even after a user clears browser history? I'm working on a PWA targeting the latest Chrome. Running `await navigator.storage.persisted()` on a dev tools console with the app open returns true, however doing a standard browser history clear still deletes all indexedDB data. The only thing I've managed to find is this article from 2016 that mentions that this is feature is in development: https://developers.google.com/web/updates/2016/06/persistent-storage.
|
# ? Feb 8, 2019 09:47 |
|
React Hooks are out and they're fantastic
|
# ? Feb 8, 2019 23:03 |
|
prom candy posted:React Hooks are out and they're fantastic They are indeed. Here's my first pass at using them for something practical. Cancellable in-flight HTTP requests with Axios and hooks (and TypeScript): JavaScript code:
teen phone cutie fucked around with this message at 09:05 on Feb 9, 2019 |
# ? Feb 9, 2019 08:57 |
I don't really understand the point of React Hooks. If your component is sufficiently complex that you need state and lifecycle methods, why not make a class? Isn't the whole point of functional components that they are simple functions from props to JSX? Putting state inside a function just seems like an anti-pattern to me.
|
|
# ? Feb 9, 2019 09:17 |
|
Reusing state and less expensive testing to name a couple. I feel like ppl who’ve used and tested Recompose wrappers can most easily see the benefits
|
# ? Feb 9, 2019 09:26 |
|
Grump posted:Reusing state and less expensive testing to name a couple. can you give an example? because i don't see it either
|
# ? Feb 10, 2019 04:17 |
|
Let's say you've got some logic that requires you to do some setup in componentDidMount, then some prop diffing and updates in componentDidUpdate, and then maybe some teardown in componentWillUnmount. Already this kinda sucks, you have related logic spread across 3 methods. Now let's say you want to reuse this logic in another component. And for arguments sake, let's say that other component is also doing a couple of things in life cycle methods. Pretty quickly you've had to copy and paste code, or make a higher order component, or a render prop component, and all those things come with their own downsides. Hooks basically let you package up and reuse related stateful logic. Take a look at the Rooks project for some good examples of simple but powerful reusable hooks.
|
# ? Feb 10, 2019 05:26 |
|
I still have not read a single thing about Hooks because they were announced 2 days after I just got done updating the two applications I develop to React 16. All I did was sigh and then become extremely tired.
|
# ? Feb 10, 2019 08:45 |
|
You can completely ignore them for now but eventually a library you want to use will probably only exist as a hook. Even then you'll probably go "oh okay this makes sense." For the most part if you already understand React you'll be able to learn hooks in like an hour. There does seem to be a huge contingent of React devs who are like "gently caress hooks, classes for life!" I have a strong feeling these are some of the same people who were originally like "gently caress React, jQuery for life!" Some people just don't like change.
|
# ? Feb 10, 2019 15:47 |
|
Writing hooks seems like it has a bunch of gotchas but using them seems pretty straightforward.
|
# ? Feb 10, 2019 15:57 |
|
I think the only thing that's both weird and common is the API around useEffect. You have to return a function from it to do any teardown (basically what would've been your componentWillUnmount method) and your second argument is your dependencies. The dependencies thing is weird because if you omit it then your effect runs on every render and if you only want it to run on first render you have to pass an empty array. It seems a little bit overly terse to me but once you learn those rules it's not hard to remember. All the other common hooks (useState, useRef, useContext, etc.) are pretty straightforward and work just about how you'd expect. I've been switching some components to hooks and writing a couple of custom ones and I really like it. Control flow in my components is way cleaner and there's no more wrapper hell.
|
# ? Feb 10, 2019 16:39 |
|
This should explain why you would want to use Hooks. https://www.youtube.com/watch?v=dpw9EHDh2bM
|
# ? Feb 10, 2019 22:15 |
|
What's the best way to do live reload for a brand new project in TYOOL 2019? For reference, I'm using VS Code + Typescript to create my own toy framework for fun. I'd like to provide live reload for simple styling, editing static content, and maybe some basic Javascript. Last time I did this was ~4 years ago, using NPM scripts with the live-reload package. I don't know if that's still the best way or if newer approaches have taken over. I'd like to avoid committing to specific frontend framework tooling like React or Ember, or task runners like Grunt, if I can.
|
# ? Feb 11, 2019 19:07 |
|
Kobayashi posted:What's the best way to do live reload for a brand new project in TYOOL 2019? https://nodemon.io/
|
# ? Feb 11, 2019 19:53 |
|
Does anyone have experience working with preventing concurrent requests when refreshing a JWT token using rxjs and redux observables? I have some middleware that looks like this: JavaScript code:
teen phone cutie fucked around with this message at 05:02 on Feb 12, 2019 |
# ? Feb 12, 2019 04:55 |
|
Grump posted:Does anyone have experience working with preventing concurrent requests when refreshing a JWT token using rxjs and redux observables? I don’t know squat about rxjs, but you are storing a “I am trying to get a new token” flag in app state / redux store when you make your first request and check for it before you fire a second one, right?
|
# ? Feb 12, 2019 05:09 |
|
Lumpy posted:I don’t know squat about rxjs, but you are storing a “I am trying to get a new token” flag in app state / redux store when you make your first request and check for it before you fire a second one, right? What’s the benefit there? I have multiple requests that are firing concurrently on page load, so there would be some race conditions if I added a flag when the token was refreshing
|
# ? Feb 12, 2019 05:56 |
|
Grump posted:What’s the benefit there? I have multiple requests that are firing concurrently on page load, so there would be some race conditions if I added a flag when the token was refreshing You said you wanted to avoid duplicating token refresh requests, right? The benefit of knowing one is in progress is to avoid sending another. Maybe I don’t understand your question/ problem.
|
# ? Feb 12, 2019 12:13 |
|
ah okay yeah I don't think I explained well. I have 3 API requests that are running concurrently on page load. The point of that middleware is to intercept every single request and say 1. If the auth token is expired, run some request to get a new one 2. When this happens, re-run the original request 3. Queue the remaining 2 network requests until after the refresh request has finished My issue here is that the other 2 network requests are firing before I can refresh the token
|
# ? Feb 12, 2019 14:27 |
|
Grump posted:ah okay yeah I don't think I explained well. Sounds like you pretty much want what he suggested. Add a Boolean like isFetchingNewToken and wasNewTokenFetched. The first can be used to make sure no requests go out while the fetching is happening and the second will trigger the requests to happen once the token is retrieved.
|
# ? Feb 12, 2019 14:33 |
|
ok gonna try that tonight. I fully admit this might just be me not considering the most obvious solution
|
# ? Feb 12, 2019 15:20 |
|
Yeah adding that flag totally worked. This was for an interview test, so I probably shouldn’t have, but I basically stripped out all the rxjs and other already provided redux middleware for my own custom redux middleware and Axios. I ended up simplifying it a lot and hoping the interviewer sees that. I’ve actually never had a test like this that expected me to jump into a feature with a bunch of really opinionated code. From my experience, rxjs and redux don’t mix well and I’m hoping to talk about that if I get to the next round
|
# ? Feb 13, 2019 20:16 |
|
|
# ? Apr 28, 2024 00:05 |
|
I can't really speak for them but a possible idea is that they wanted to see what you would do when given constraints. As you mention it gives you a good opportunity to explain your thought process and why you re-wrote the code It's either that or they thought they were helping you out
|
# ? Feb 13, 2019 20:58 |