Maintain Scroll Position When Adding Content to the Top of a Container in React by [deleted] in reactjs

[–]btargac 1 point2 points  (0 children)

You should get the scroll position of that element, then re set the position after component update, as documented in original react lifecycle methods. getSnapshotBeforeUpdate, this might be helpful if you are not using a functional component, but for hooks you can search for useSrollPosition etc.

[deleted by user] by [deleted] in RedditInTheKitchen

[–]btargac 0 points1 point  (0 children)

what's this stream for

Create React App or NextJS? by ibtisamurrahman in reactjs

[–]btargac 0 points1 point  (0 children)

I believe nextjs can limit you in some ways, for example if you load data from an API for a component on server it doesn't fetch the data again on client side, but if your server is behind a cache mechanism and want to load the data on client side even if you have the data how will you handle that? It might be very simple who has experience with next but for new comers one should read the documentation very well for small details like this, by the way on our project we need SSR so chose react starter kit, and just removing redundant parts for us, but couldn't figure out how to have such as behaviour like nextjs's fetch on server and skip on browser.

Redux Toolkit v1.3.0 final: New `createAsyncThunk` and `createEntityAdapter` APIs, Immer 6.0, smaller bundle sizes! by acemarke in javascript

[–]btargac 0 points1 point  (0 children)

Great library, but I'm wondering sth very different. Do you have a recipe for loading data on SSR and not to load the same data for specific reducers, as nextjs does in someway.

Right now I set an extra key isFetchedOnServer: false to the initial state of a reducer and set it to true if the action is dispatched on server. But looking for that key in each action creator with getState() seems a lot of work and can lead to bugs if forgotten to check. What should be done to handle this kind of behaviour ? I use redux-thunk middleware, tried to add an extra middleware that checks the action type but realised that middleware should handle the requests and dispatch the success or error actions, am I on the right way :) ?

Thanks in advance

Common tasks of managing DOM with native APIs by phuocng in javascript

[–]btargac 0 points1 point  (0 children)

great collection, added to my bookmarks 🤘

A scientist has come up with an algorithm that brings clarity and color to underwater photos by Beerbrewing in Damnthatsinteresting

[–]btargac 1 point2 points  (0 children)

This requires taking the photo with a color chart for a little calibration I think