React Update certain values after initial rendering - reactjs

I have an inherited React app that i need to fix but after a few days, im stuck and need help.
I have a filtering panel on the left side which contains a 5 categories and items within their categories below it, each item has a checkbox next to it and when you click it, it updates the results on the right side, this works fine.
However i have a task to update the numbers next to the links in the filter panel, based on what was clicked and would like to know if there is a way to create the filters links first and then only update the number next to the link upon click.
All the code resides in the render method, any help would be great.

Related

How to dynamically add a new form step to react multi-page form for each selected item on the first page?

I need a bit of direction. I'm working on an application with React, Typescript, and Material UI. I've created a simple modal. The first page contains an MUI DataGrid with checkSelection enabled. The User can select as many options as appear on the table.
Now, for each selection, the User will then have a new form step to complete. So, if the User selects 5 items from the table, they will then see 5 corresponding steps. The form steps are tied to the selection. So, if the first selection is a menu item, for example, then the next step in the form will be about that menu item, with fields to add to that item.
I've been searching for a similar solution and haven't found one. I'm hoping that someone can point me in the right direction or has some sources they can recommend.
Much appreciated.

Angular JS doesnt update the view even though the model is updated

I have been struggling to see this behavior for past few weeks where the angular JS model has been updated but the UI doesnt get reflected in the multi select box.
Absolutely no errors and the data model has all the values it needed . I tried reloading controller and also doing a refresh inside controller to take changes.
tried $scope.$apply() as well and its of no use. If anyone from angularjs team is ready to take a look, we can discuss over call and i can share more about the code. Unfortunately due to sensitive information i cannot copy paste the code here.
editing main question:
example: I have an object something like this. var clusters = { available: [], selected: [], } and have 2 multiselect controls. One will show all the available ones and when user selects one it will be pushed into selected list to display in second multi select control . for the first time when page loads, if the user already selected anything, I will get this data from db. and try to display to the user what he selected previously. This is where , angularjs doesnt bind the values in the selected list when shown. The UI doesnt reflect i even though i successfully added the list in the array(selected).

React native zoom in effect when click item in grid view to detail view list

I'm new with react native, and I'm trying to achieve the exact same effect as Instagram or TikTok when you click an item in a gridview it opens up a listview with details of the items with a zoom in effect.
For now, I have a gridview, where data load with a limit of 10 items and when reaching the end gets the next 10 items. In order to try and achieve what I want to do, been searching but can't seem to figure out the right approach.
Should I have both list in the same screen, but how do I get the app to do the zoom in effect and open the detail view at the right index item ? Or should I have both list in separate views, but how do I keep the data synced ? Or is there another way that I'm missing and keep seem to find ?
Image might help understand (taken from instagram)

View more and view less button with React query

In my React app, I have a page that when renders, it makes a fetch request using React Query useInfiniteQuery to get two items from the server and populate a list.
I implemented a "View more" button that when you click on it, it will call React Query useInfiniteQuery, fetch more data and add it to the list. I can do this X times and potentially get hundreds of items in the list.
When there is no more data to fetch I change that button to a "View less" button and when I click on it I want to do some kind of "collapse" and show the fist two items on the list.
How can I achieve this? Is there something that comes with React Query that let's me do this?
Should I just remove the items from the DOM manually?
react-query doesn't do anything dom related, it's up to you how many pages you want to render. if you have 10 pages in the cache and only want to render 2 of them - then only render 2 of them. you can also remove the other pages from the cache with queryClient.setQueryData, but I wouldn't do that.

React DnD make dropTargets when hover on something while dragging item

I'm trying to do something like below:
Scenario 1: User will drag and drop List 1 from left side to right side.
Scenario 2: Again, User will drag list 2 to right side, when that dragging item hover on list 1, have to show drop zones to drop that list 2 item here.
Finally, List 1 and List 2 both will be placed like left and right side.
With React Dnd, Is this achievable? and I tried this it works only while dragging. https://stackblitz.com/edit/react-pctpdh
I'm able to show a drop area while dragging, it shows every time, but I need to show that drop area only hover on some item.
Below is the sample work, I have to achieve:
Need to show placeholder to drop an item while hover other items to drop. (Need to Create dynamic drop targets while mouse hover some item)
I need a help on this to achieve this feature.Any idea on this really commendable.
I saw the code snippet and i added some new code that replicates your desired behavior.
The idea is to create a separate component to handle drop actions, that can be reused when is needed. In this particular case, I choose to use the component inside your ListItem component to create two drop zones on both sides.
Here is the updated code: https://stackblitz.com/edit/react-pctpdh

Resources