Dynamically update URL on every button click on Component
I’m basically a newbie to react. And I’m currently building an app using ReactJS, so here’s my problem. I have this Modal
and Home
components. Whenever I click a Card
component that is mapped from my JSON file from one of the components in Home
. It will show a modal where it will display a set of data from a JSON file. Then there is another Link to
inside the modal where it will randomly generate and pull data from my JSON and re use the Modal component to display a new set of data. The thing is, I have used React Routing(dynamically routing) but it’s not updating the URL based on the unique key(id) from my data. I tried using generatePath and navigate, but I guess i’m a little bit lost. Here’s a little preview of my code:
Pagination is not working properly using React-Router DOM
I am trying to do pagination for components named “”, and using react-router-dom.
To store the URL paths I have used an array.
A state variable is used as an array index to retrive specific paths.
useRef is used to store specific path and change it whenever “next” or “prev” button is clicked.
refetching data after using useLoaderData
I trying to refetch data or rerendering my component after submitting the form but did not work . for example here I’m displaying review’s count , when I submit the form I’m getting only the response of new added trip but the component itself doe not reload and the review’s count is not changing unless when i refresh the page manually
notice : I’m using loader and actions (react router) for making requests
<p>+{reviews.length} reviews</p>