Instead of writing my components inside a class, I\'d like to use the function syntax instead.
How do I override componentDidMount, componentWillM
You can use react-pure-lifecycle to add lifecycle functions to functional components.
Example:
import React, { Component } from 'react';
import lifecycle from 'react-pure-lifecycle';
const methods = {
componentDidMount(props) {
console.log('I mounted! Here are my props: ', props);
}
};
const Channels = props => (
Hello
)
export default lifecycle(methods)(Channels);