1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/examples/with-higher-order-component/components/withApp.js
David Nguyen 3c71e818bf Example/add high order component example (#2331)
* temporary commit

* update code

* completed example higher order component

* remove custom server
2017-06-21 19:45:06 +02:00

27 lines
538 B
JavaScript

import React from 'react'
function withApp (Child) {
return class WrappedComponent extends React.Component {
static getInitialProps (context) {
return Child.getInitialProps(context)
}
render () {
return (
<div>
<header>
<h1>Header</h1>
</header>
<main>
<Child greeting='Hello From HOC' {...this.props} />
</main>
<footer>
<h1>Footer</h1>
</footer>
</div>
)
}
}
}
export default withApp