??. Of course, you don’t need TypeScript to use it — you can either configure Babel to enable this feature, or just wait until it lands in the ECMA standard.
Let’s talk about why you’d want to use it, rather than the usual double pipe operator. Consider this example:
The boolean problem
const chickenPref = false;
const globalPref = true;const serveUserChicken = chickenPref || globalPref; // evaluates to true
This user has been crystal clear that she does not like chicken — but the OR operator (||) doesn’t care. It will still continue and evaluate the
globalPref, as if the
chickenPref has not been defined. Why? Because the OR operator doesn’t care what exactly the value of the left operand is —it coerces the left operand into a boolean, and if it’s false, it’ll continue to evaluate the right one, resulting in one unhappy user. …
I suspect that there’s a certain personality type that is drawn to programming. The type of person that must be solving problems and learning new things, because without this drive, it’s hard to get ahead. But this career drive can be a double-edged sword, making it difficult to maintain a balance in life and prevent long-term damage to one’s health.
When I got my first real coding job at a Rails consultancy, there were a few lifestyle changes that came along with the new job that I didn’t pay much attention to at first, but over time had insidious consequences. For one thing, I now had a decent paycheck. I also didn’t have much free time anymore. …
Ant (GitHub) is much more than a React UI kit with a minimalist design aesthetic and every component under the sun. It is a rabbit’s hole that leads to a giant maze of interconnected libraries, with a serious ecosystem surrounding it. There’s a custom build tool based on Webpack called ant-tool, several CLI apps, community scaffolds, and a complete framework (dva, which has its own CLI as well). And the UI components are mini-projects in and of themselves — see this repo for information on each component.
Many of these libraries appear to be very polished, including an entire React animation library. And I’d love to learn more about them, but Ant comes with a challenge — the majority of the documentation is in Chinese. …
Warning! This design post does not contain any drawings or diagrams. It’s a different approach, but hang in there — I find that it makes it easier to remember concepts when you have to visualize them yourself.
Fetch is a fantastic networking API that was chosen for React Native, but because it is relatively new, there are a few things to be aware of when using it. The React Native Documentation does include a single example, which is a good start, but I want to add a few more things that may not be readily obvious.
Sending a GET request to a JSON API is the simplest use case. Just call fetch and supply it with the appropriate URL. It returns a promise that can be parsed as usual:
When submitting a POST request, supply the URL as the first argument and an object containing the request information as the second argument. …