import React from 'react'
import {useState} from 'react'
import ReactDOM from 'react-dom'
function App(props) {
const [count, setCount] = useState(props.initCount)
const handleClick = () => {
setCount(count + 1)
}
return (
<div>
<p>Count: {count}</p>
<button onClick={handleClick}>Increment</button>
</div>
)
}
function HighOrderComponent(WrappedComponent) {
return class createdComponent extends React.Component {
state = {
initialState: 5,
}
render() {
return <WrappedComponent initCount={0} />
}
}
}
let AppHOC = HighOrderComponent(App)
ReactDOM.render(<AppHOC />, document.getElementById('root'))