i am working on one reactjs project - where i need to check after every 30 minutes if user have a subscription plan then show ui otherwise hide- The subscription plan details is stored in the local storage.I don't want to use any low level function like use setInterval. Please suggest some optimzed answer.
Related
I built an admin page in React.js to check for new orders placed, but I used a useEffect with setInterval for a specific duration (30 seconds for example) to keep on fetching new orders from the backend and mysql server.
Is this a bad pattern or not? Is the a better way , maybe to notify the admin that there are new orders then he will refresh manually?
Thanks!
I currently have a React App that is using Axios to post data to a Python backend. The jobs are heavy and could take anywhere from 30 seconds to 5 minutes.
Currently, the application sits there loading until the job is done. If you navigate away from the page, while the backend process finishes, the frontend process no longer catches the response due to leaving the page.
I'd like to set it up so that the job continues to run, the user can navigate away from the page and do other things on the app. Then, when the job is complete, it updates the state (which prompts a notification to appear that the file is ready).
Does anyone know how to do this? Can maybe point me in the direction of some documentation that goes over this type of functionality?
Appreciate the help!
I am creating an eCommerce-type website with react and Laravel with the REST APIs. Every time user enters page www.mywebsite.com/products a rest API is called to get all the products, and it takes like a second to load all of them. If the user leaves the page and enters it again, the same request is called, and the same products are loaded.
My question is: What's the best approach for this situation? Maybe I should somehow fetch the products only once, store them inside localStorage and get them using Context? On the other hand, most of the websites I visit seem to load products instantly, so maybe even the REST API is the wrong approach for this kind of website?
I would suggest to check your DB queries and investigate why this request takes so long. Have a look at the laravel Telescope package: https://laravel.com/docs/9.x/telescope
In the request tab you can follow your requests and see which queries are the most expensive ones. My guess is that you're lazy loading some relations on each product.
Next I would propably cache the articles (expect maybe the stock information). Use the built-in feature of laravel or maybe a third party package like this one
Only then I would go for client-side optimizations. Here you should consider maybe a state management extension like akita.
I am working on a project that shows live currency prices. I have to refresh the pricing data on the page dynamically. In this project I am using Django and SQL server. I could not figure out how to make it work using triggers and AJAX because AJAX needs an event to run like a user event or timer (that very bad for performance). Further, triggers can not be processed by Django. Is there a way to do it? Thank you for your help.
Is it appropriate to create a stop watch web app based on firebase?
Actually what I want to know is that :
whenever the stop watch's time change every second ,
is it appropriate to update the changed time into firebase DB every second?