This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ClassComponent extends React.Component { | |
| render() { | |
| return "I'm the class component"; | |
| } | |
| } | |
| /* | |
| var ClassComponent = function (_React$Component) { | |
| _inherits(ClassComponent, _React$Component); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const FunctionalComponent = () => { | |
| return "I'm the functional component"; | |
| } | |
| /* | |
| var FunctionalComponent = function FunctionalComponent() { | |
| return "I'm the functional component"; | |
| }; | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| shouldComponentUpdate(nextProps, nextState) { | |
| return nextState.message !== this.state.message; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import ReactDOM from "react-dom"; | |
| class ClassComponent extends React.Component { | |
| render() { | |
| console.log("Regular class component has been rendered!"); | |
| return "I'm the class component"; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import ReactDOM from "react-dom"; | |
| class ClassComponent extends React.PureComponent { | |
| render() { | |
| return "I'm the class component"; | |
| } | |
| } | |
| const RenderClassComponents = () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, {Component} from "react"; | |
| import ReactDOM from "react-dom"; | |
| class ClassComponent extends Component { | |
| constructor() { | |
| super(); | |
| this.state = { | |
| message: "Hello" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import ReactDOM from "react-dom"; | |
| class ClassComponent extends React.Component { | |
| render() { | |
| return "I'm the class component"; | |
| } | |
| } | |
| const RenderClassComponents = () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import ReactDOM from "react-dom"; | |
| const FunctionalComponentWithProps = (props) => { | |
| const fullName = `${props.name} ${props.surname}`; | |
| const handleClick = (event) => { | |
| alert(fullName); | |
| }; | |
| return ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import ReactDOM from "react-dom"; | |
| const FunctionalComponentWithProps = (props) => { | |
| const fullName = `${props.name} ${props.surname}`; | |
| return `Hello ${fullName}`; | |
| }; | |
| const RenderFunctionalComponents = () => { |
NewerOlder