So, you got an API and you want to use it in the frontend. How do you process the response data? Are we good to go with a
I have seen many frontend projects just use whatever the API returns directly without further processing, and I would…
Great, so we both on the same page in regard to the principle of components' responsibility boundary.
Now it might be your turn to explain more about why we *have to* do it with pure CSS (and with margin)? Does it sound very dogmatic? …
When coding for UI layout, we need something to represent the spacing between elements, and yes, we have been using
margin for a long time.
However, when using a component-based framework such as
React, we may need to rethink if
margin is still the best choice.
Here are my thoughts:
In React Testing Library, there is no global configuration to change default timeout of
waitFor, but we can easily wrap this function to provide our own default values.
That is, we can create a
waitFor.ts file under
test-utils folder as shown below:
In this file, we import the original…
In this article, we will go through the following sections:
Now, let’s get started.
Early Return is a pattern that suggests us to avoid nested
if-else statements by…
Github Repo: https://github.com/zzdjk6/simple-abortable-promise
Promise can’t be aborted or canceled. It can only be
Trick: But we can
Promise early if we want :)
Let’s face it, we all have the needs to abort or cancel the
Promise sometimes. For example, in a single-page…
When dispatching async actions with
redux-thunk, we usually have three actions for each thunk:
FAILURE. Imagine we have a thunk to fetch data, we would dispatch
FETCH_DATA_REQUEST before we send the API request, then dispatch
FETCH_DATA_SUCCESS when the request succeeds or dispatch
FETCH_DATA_FAILURE when the request fails.
npm install redux-thunk-routine
redux-thunk gives us the ability to create asynchronous actions, but do you feel that you are writing boilerplate code again and again?
Do you feel things are getting even worse when you trying to add static typing?
Inspired by redux-saga-routines which is a library for
The original idea is from this blog, but I prefer a more clear and simpler way to describe and implement this feature, so there is a blog post here :)
At the very beginning, let’s review how we utilize GraphQL over HTTP(s) protocol in its essential: