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"; | |
| export default function ShowEmployeeSalaryDetails(props) { | |
| return ( | |
| <div> | |
| <p>Employee Name: {props.name}</p> | |
| <p>Employee Salary: {props.salary}</p> | |
| <p>Employee Bonus: {props.bonus}</p> | |
| </div> |
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"; | |
| var HigherOrderComponent = function(WrappedComponent) { | |
| return class EmployeeDetailComponents extends React.Component { | |
| constructor() { | |
| super(); | |
| this.state = getEmployeeData(); | |
| } |
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
| var EmployeeBasicDetails = HigherOrderComponent(ShowEmployeeBasicDetails); | |
| var EmployeeSalaryDetails = HigherOrderComponent(ShowEmployeeSalaryDetails); | |
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
| function getEmployeeData() { | |
| return { | |
| name: "Mayank", | |
| age: 30, | |
| designation: "Developer", | |
| salary: 30000, | |
| bonus: 2000 | |
| } | |
| } |
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 EmployeeDetails extends React.Component { | |
| constructor() { | |
| super(); | |
| this.state = { | |
| name: "Mayank", | |
| age: 31, | |
| designation: "Senior Developer" | |
| } | |
| } |
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, { useState } from "react"; | |
| export default function EmployeeDetails() { | |
| const [name] = useState("Mayank"); | |
| const [age, setAge] = useState(31); | |
| const [designation] = useState("Senior Developer"); | |
| function updateEmployeeAge() { |
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 [name, setName] = useState("Mayank"); | |
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
| var stateVariableForName = useState("Mayank"); | |
| // Getter for the state value created.. | |
| var name = stateVariableForName[0]; | |
| // Setter for the state variable created.. | |
| var setName = stateVariableForName[1]; | |
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
| function EmployeeDetails(props) { | |
| return ( | |
| <div> | |
| <p>Employee Name: {props.name}</p> | |
| <p>Employee Age: {props.age}</p> | |
| <p>Employee Designation: {props.designation}</p> | |
| </div> | |
| ) | |
| } |
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
| function* customGenerator() { | |
| yield 1; | |
| yield 2; | |
| yield 3; | |
| } | |
| var getIterator = customGenerator(); | |