What are React Hooks?

React Hooks were introduced at React Conf October 2018, where two major functional
components were highlighted – useState and useEffect. Function compontents were initially known as functional stateless components (FSC), where they are finally able to
useState with React Hooks. Therefore, many people refer them as function
components.

Hooks let you “hook into” the underlying lifecycle and state changes of a component
within a functional component. More than that, they often also improve readability and
organization of your components. We can check 2 hooks that are used regularly while
using React Js.

1) useState:
import React from 'react';
function App() {
return (
<div>
<h1>0</h1>
<button>Change!</button>
</div>
);
}

In this above example, this is a simple functional component in which we can import our
first hooks useState for Handel state data.

import React, { useState } from 'react';
function App() {
const value = useState();
console.log(value);
return (
<div>
<h1>0</h1>
<button>Change!</button>
</div>
);}

If we run this code and console the data then we can get a response as below
> [null, ƒ()]
And if we add an argument into use state
const value = useState(true);
we can get a response as below
> [true, ƒ()]
Now we can access state value and render it in <h1> in our component such as


import React, { useState } from 'react';
function App() {
const value = useState(0);
console.log(value); // [0, ƒ()]
return (
<div>
<h1>{value[0]}</h1>
<button>Change!</button>
</div>
);
}

There are 2 types of functionality that store data into use state

1) Object destructuring
2) Array destructuring

Array destructing is almost the same, but uses square brackets [ ] instead of curly
braces { }.
Using array destructuring, we can get the initial value of state from the useState() hook.

import React, { useState } from 'react';
function App() {
// remember, there's a second item from the array that's missing here, but we'll come
right back to use it soon
const [count] = useState(0);
return (
<div>
<h1>{count}</h1>
<button>Change!</button>
</div>
);
}

Right now we can get initial state value but how we can change the value in hooks that
are described in the below example


function App() {
const [count, setCount] = useState(0);
function change() {
setCount(prevCount => prevCount + 1);
}
return (
<div>
<h1>{count}</h1>
<button onClick={change}>Change!</button>
</div>
);
}

Here we first set initial count to use state is 0 then for an update that
counts we can use onclick event listener on button click.
Remember that useState() hook returns an array with 2 members. The second
member is a function that updates the state!

2)useEffect

In class-based components, we needed to know the basics of lifecycle methods and which
method is perfect for different situations. useEffect hook simplified this situation. If you wish to
perform side effects, network request, manual DOM manipulation, event listeners or timeouts
and intervals.
useEffect hook can be imported just like useState.

import React, { useState, useEffect } from 'react';

To make useEffect work, we pass it an anonymous function as an argument. Whenever React
re-renders this component, it will run the function we pass to useEffect

useEffect will run every time the component re-renders, and the component will re-render every
time the state is changed.
So if we write the following code, it will get us stuck in an infinite loop! This is a very common
gotcha with useEffect

If you want to call useEffect on some call function that also possible in react hooks.

Updates of AMP in 2019

Since 2016 Google has been giving businesses an opportunity to focus on their websites mobile experience. The release of Accelerated Mobile Pages was a clear indicator of how Google was trying to prioritize the mobile-first approach. If you do have an online business are not optimizing your website for a faster, smoother, & richer mobile experience, then you’re definitely setting yourself up for failure. In this blog, we will be looking at the evolution of AMP & its current state of progress at the moment.

The Evolution Of AMP

As I’ve mentioned before AMP was launched during 2016. It was an open-source project by Google which combined the development efforts of millions of people to ensure faster delivery of data on mobile pages. What AMP does is, it removes all the “unnecessary” clutter that might be delaying the loading of the pages. From what you can see, you’ll notice AMP pages will be without too many images, they’ll have a simple font. Under the hood, the CSS will be optimized for faster delivery of data, HTML and JS code will be delivered as a first in first out basis.

History Of AMP

Since releasing in 2016 AMP have been the talk of the town among Digital Marketers all around the world. Digital Marketing professionals and tech enthusiasts are both looking at AMP pages from the perspective of gains. While marketing professionals see it as another method of lead gen through articles, the IT dept is looking for ways to go even faster. But lead forms were not always available and have only been recently introduced leading to a spike in the popularity of AMP pages, ensuring 900,000 businesses online are currently using AMP for some if not all their pages.

While AMP pages were initially built to deliver news faster, companies have adopted it to suit their requirements for a variety of different pages. Brands are focused on AMP developments for their product pages as they’ve seen a significant bump if buy-ins from the customer based on faster data delivery. Especially e-commerce players who say an increase of up to 20% in their sales figures as compared to companies that did not use AMP.

All AMP Updates of 2019

In the first quarter of 2019, some interesting updates were released by the AMP team. Let’s look at some of the most interesting one’s below:

1. Video Optimization on AMP

One of the most important updates to AMP in 2019 has been the video optimization efforts that have been taken. As a digital marketing company in Pune helping small business access the gains of AMP, we know the importance of video in a marketing strategy. Three new updates have been made,
i. Videos can now be docked so that the user can continue to scroll as they are reading their content
ii. You can now install a video player that has AMP video interface features you might need as a business
iii. You can use the AMP video optimization to run ads and keep a track of them on your website

These three features have really come as a blessing to video marketers, especially who were recently seeing a decline in watch times across the internet.

2. Input Masking

Lead gen on AMP pages is just in a nascent stage but it is still an extremely necessary step that needed to be taken. One large step forward for AMP lead gen pages is that you can now customize what you form should look like to a large degree.

3. Smoother List Scrolling

Since the internet is filled with the list, & one of the most common actions users take on their phone is to scroll, AMP has now enabled smoother scrolling options while the page is in development. You can set the grid and, resize the containers to provide the best experience to the users.

Conclusion

Very few businesses in India are taking advantage of AMP pages as there are not too many digital marketing companies in Pune that are technically capable of providing that solution. If you want to know what CodePlateau can do for your business, get in touch with us today!