[React.js] Function and Class Component Template
There are two way to create a React Component.
Different things are a Class component
can use “State” and “Life Cycle Methods”.
But recent version of Function Component
also use “State” features using Hook and Function Component
is simpler than Class Component
.
React recommand to use functional component for the future.
More information: React.js Component and props
Default React Class Component
import React, { Component } from 'react';
class classComponent extends Component {
render() {
return (
<div>
</div>
);
}
}
export default classComponent;
Default React Functional Component
import React from 'react'
const functionComponent = () => {
return (
<div>
</div>
)
}
export default functionComponent;
Comments