Smart Mistakes Are the Worst
Tuesday, May 22 2018
When writing bad code, playing smarter sometimes gives the worst results.
How to wrap a web REST API
Wednesday, Apr 4 2018 in java
When calling into a third-party REST API, it’s OK to define high- and low-level operations, and leave out the middle.
Lone Heroes on Software Projects
Sunday, Mar 25 2018
On a software project, communicate to colleagues, managers and clients when you’re in trouble:
Monday, Mar 12 2018 in mathematics
Bit operations preserve De Morgan’s laws. Bit values are sequences of symbols. What makes them behave like booleans? Where does the essence of a boolean lie?
Validate like a Native with React
Validating a form doesn’t always require a lot of code. With HTML5 constraint validation, you can describe form validation rules with HTML attributes on the form fields.
For example, to enforce that an
<input>element should not be empty, add the
requiredattribute to the element:
<input id="name" name="name" required/>
You can use HTML5 constraint validation even with React. Let’s look at an example.
How to turn an HTML form into JSON
To send data from an HTML form to a JSON API, you can extract all the form data in one go with
React and refs, an eternal love story
As in our previous exercise, we want to get the DOM node for a form component to validate the form with the HTML constraint validation API.
Since React 16.3, we can store references to DOM nodes with
React.createRef(). Let’s repeat the exercise with the new API.
React, forms and DOM nodes
To validate a form with the HTML5 constraint validation API you need to call
.checkValidity()on an actual
<form>DOM node. With a custom React form component, how would you access the constraint validation API inside a parent component?
3 Ways to Fine-tune Presentational Components
Here are three ways to make React presentational components work as re-usable building blocks.
React and the mysteries of this
What’s going on with
bind()do? Let’s explore how
bind()on some methods in your class component constructors.
Introducing React Lifecycle Methods
So-called lifecycle methods come in handy to change the default way React renders elements, like if you want to manipulate the DOM directly or compare the previous and the current props. In this post, we’ll examine three of the most common lifecycle methods. Since you can only use lifecyle methods in class components, let’s remind ourselves the difference between class and function components.
Three Steps to Learn React
Saturday, Sep 16 2017 in react
Have you looked at the React documentation already, but are still confused about how to go about building your first prototype? Try these steps on the path to React mastery.
3 Web Servers for Frontend Developers
I did everything right… and npm throws EINTEGRITY errors!
In my React book, I explain how to download your frontend project dependencies with npm; in this blog post I am going to explain how to recover from an oddball error that I’ve come across once or twice.
Make small React components
Sunday, May 21 2017 in react frontend
The more I experiment with React, the more I find small presentational components are the way to go. Take this markup for a panel component:
Create a Cloudfront distribution for an S3 website
Tuesday, May 9 2017 in devops frontend
The HTTPS protocol encrypts the data between your website and the browser; it makes it harder for third-parties to inject their content into your website and may boost search rankings. You can’t use HTTPS if you’re hosting a website on an S3 bucket on your own domain. To serve your S3 website with HTTPS, one solution is serving your website through the Amazon Cloudfront CDN.
Long term caching with webpack and templates
Saturday, Apr 22 2017 in frontend
Far future expiry on your CSS and JS resources ensure visitors load them from cache as often as possible, improving page speeds and reducing bandwidth costs. But it can be complicated to force visitors to load a new version before the old one expires. CDN amplify the issue. When you distribute your assets to a CDN like Cloudfront, the CDN servers all over the world only request a new copy when the assets expire.
To decide which technologies to cover React book, I’ve developed the same example with Redux and MobX. While I ended up with less code with MobX thatn with Redux, I’ve found out that structuring an application with MobX still requires rethinking your data structures compared to a plain React application. get() and set() everywhere One advantage of React is that you can think about each component separately. Define the props that you need for a section of the interface and you’re good to go.
Taking Glimmer for a ride
Is React hard to learn?
Monday, Apr 3 2017 in react
Paradoxically, React might feel more difficult at first than other frameworks because it is simpler in the sense that it uses more general, less ad-hoc mechanisms. The Vue documentation is amazingly well-written. But I suspect Vue sometimes feels easier because each concept that you need to build an application with Vue.js maps explicitly to a part of the Vue.js API. For example, the UI is not just the return value of a function; it’s labelled template in the actual code that you write.