Last active
August 13, 2019 07:40
-
-
Save Mayankgupta688/ff74c2afd77b216158a7de72d2098e4c to your computer and use it in GitHub Desktop.
This file contains 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(); | |
} | |
render() { | |
return ( | |
<div> | |
<WrappedComponent {...this.state}></WrappedComponent> | |
</div> | |
) | |
} | |
} | |
} | |
function getEmployeeData() { | |
return { | |
name: "Mayank", | |
age: 30, | |
designation: "Developer", | |
salary: 30000, | |
bonus: 2000 | |
} | |
} | |
var EmployeeBasicDetails = HigherOrderComponent(ShowEmployeeBasicDetails); | |
var EmployeeSalaryDetails = HigherOrderComponent(ShowEmployeeSalaryDetails); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment