Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 months ago.
Improve this question
When making API calls in React, should they all be asynchronous?
Is this a one-size-fits-all answer, or is this scenario-based? If so, what are some good examples of where to use async calls, and where not to use them?
The only way to perform sync API calls is by using XMLHttpRequest in a very particular fashion which was deprecated a long time ago.
More modern APIs like fetch do not support sync requests even as 1st April joke.
So, yes, it's a very good idea to keep your API requests async, always.
Sync requests are problematic, make your app perform really bad & are just conceptually silly.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 days ago.
Improve this question
I've been reading up on how to store jwt tokens in React, and this particular topic seems to be a hot topic for 2 reasons:
the browser is not that secure when it comes to storing sensitive data
the alternative is to build a sort of middleware between the browser and the backend that allows you to encrypt and store your jwt token in a way that it's kept separate from your backend data
can someone please point me in a direction with code-examples?
there are LOADS of theoretical discussions out there, but very few actual guides...
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 months ago.
Improve this question
Is it possible to temporarily cache all requests in the Rails backend?
Sometimes it's helpful to make frontend stuff without waiting for the backend on the page to reload.
Your question is very ambiguous. If you don't want to wait on the backend for development then you can cache your requests on the front-end using local storage or other client-specific APIs.
On the other hand, if you need backend caching it won't really serve your purpose because the client will still need to make the API call.
Lastly, if you need to mock your APIs then there are multiple such tools available. One that I like is https://designer.mocky.io/
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I am trying to understand the best practices when writing and achieving the best abstraction. Should all functions be action creators when writing redux-react applications, or should functions where it is not necessary to edit the store go directly into components and be called from there?
Action creators are for managing state. They are a very specific type of function that generate actions that are processed by your reducer. There are a lot of other computations and things you can do in your app besides manage state, and for those things you should not use action creators. You don’t necessarily have to put the functions in your components. You can also put them in a helper folder, for example, and then import them.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed last year.
Improve this question
For my React Dapp to call my smart contracts running on the ethereum block chain, is it better practice to use the Drizzle framework or call Web3 directly?
I recommend using drizzle because it will abstract some complexity and make your code more readable. Also check out drizzle-react it provides some components and decorators that will be super useful.
However, be careful with this type of questions in SO, it might get downvoted, since it's kind of a subjective question and people might have different opinions about it. This community is more about solving coding problems.
Best of luck.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
AngularJS has a $timeout service which acts as a convenience wrapper around setTimeout.
Why is there no equivalent for setInterval?
Since $timeout is calls scope.apply after each call it can get expensive. However creating a simple interval you can decide what watches and apply calls are needed to keep it clean.
For example, if you interval was running once every minute to check if the user's values had changed and optionally saving it if the values had been changed since the last check. Depending on how you write the code, you may never need to update the web page, so your interval can get by without triggering an update.
That doesn't answer the question directly of why $interval isn't provided by default, but I suspect it is because since it is simple to create your own with you specific requirements, it is better to leave it open for you to enhance, instead of providing a default implementation that is too complex, or too inflexible.