Hey guys, I posted about this a little bit ago and found time to keep pushing forward and hopefully finish this project within the next two days. @DanCouper had recommended I use SWR to fetch data and clean up the main component of my application. I created a context for the fetching of data as intended for a read-only on the GET:
And I am using the context from above in the artList component here to retrieve the data:
Which is working!
However my problem is I am unsure how to make the component re-render after the change to filteredTerm from the state. It seems like SWR caches this data and doesn’t have it stored in state, so this is where I’m falling short.
Without SWR, I was retrieving the data on every filter, but that would re-render the component, filter properly based on the filteredTerm in the state, and have it working (albeit with poor performance).
Any guidance will really help. Thanks!
EDIT: Have also looked into mutate() from their docs?
EDIT2: Realized mutate() is for other requests. I’m just trying to filter currently and I’m getting a bit closer. Will have to use mutate() once I deal with the CRUD functionality.