Posts

React deprecated lifecycle methods - detailed

Here is the list of deprecated methods from react version 16 onwards: componentWillMount → UNSAFE_componentWillMount alternative - getDerivedStateFromProps componentWillReceiveProps → UNSAFE_componentWillReceiveProps getDerivedStateFromProps is going to handle what componentWillReceiveProps and componentDidUpdate did. After either a component is created or when it receives a prop, getDerivedStateFromProps is called to return a new state. componentWillUpdate → UNSAFE_componentWillUpdate alternative - getSnapshotBeforeUpdate The reasons of the deprecation are: All these three methods are frequently used incorrectly and there are better alternatives When asynchronous rendering is implemented in react, incorrect use of these methods can create trouble and interrupting behaviour of error handling could result memory leaks. Although old names can be used until react v.16.9 with a warning, but from v.17 onwards this will not be available, to support asynchronous rendering in react. Here is...

CSS - Progressive Enhancement vs Graceful Degradation

Graceful degradation  is way of building web functionality which provides a certain level of user experience in modern browsers, but it will also degrade gracefully to a lower level of user experience on older browsers. Now this lower level of user experience is not good for user visiting your website but it will allow them to use the basic functionality of your site. Progressive Enhancement is just the opposite way. Starting with basic level of user experience that all browser on earth will be able to render, and then building towards more advanced functionality and experience that will automatically be available to advanced browsers that can use it. In other words graceful degradation starts from complexity and rich functionality to use modern features of browsers, while progressive enhancement starts with a basic structure with main functionality and then constant enhancement for more rich and modern experiences, and so on for future upgrades. While degrading grac...