Skip to content

Instantly share code, notes, and snippets.

@Mayankgupta688
Last active August 13, 2019 07:40
Show Gist options
  • Save Mayankgupta688/ff74c2afd77b216158a7de72d2098e4c to your computer and use it in GitHub Desktop.
Save Mayankgupta688/ff74c2afd77b216158a7de72d2098e4c to your computer and use it in GitHub Desktop.
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