We access methods in class based component. Most of the time, we write different methods on the parent component and we pass them to child components. Let's see the implementation.
Let's add a method on this component.
```js
//index.js
import React from 'react'
import ReactDOM from 'react-dom'
// class based component
class Header extends React.Component {
greetPeople = () => {
alert('Welcome to 30 Days Of React Challenge, 2020')
The invoking or calling of the method triggers when the event occurs. Therefore, whenever you pass a method to an event listener do not invoke the method.
Now, let's the code we had add all the necessary methods.
Most of the time the container or the parent component can be written as class component and others as functional or presentational components. Data usually flows from parent components to child component and it is unidirectional. However, the latest version of react can allow us to write every component in our application only with functional components. This was impossible in previous versions.
Most of the time the container or the parent component can be written as class component and others as functional or presentational components. Data usually flows from parent components to child component and it is unidirectional. However, the latest version of react can allow us to write every component in our application only with functional components. This was impossible in previous versions.
In next section, we will cover state which is the heart of React. State allows React component to rerender when whenever there is a change in state.
In next section, we will cover state which is the heart of React. State allows React component to rerender when whenever there is a change in state.