Last active
November 9, 2017 20:05
-
-
Save jameskraus/5e7c629e85f13388ee6a669a70a065a9 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
// @flow | |
import React from 'react' | |
import ReactDom from 'react-dom' | |
class InnerComponent extends React.Component<void, { myVal: number }, void>{ | |
props: { myVal: number } | |
render = () => | |
<div> | |
My value is {this.props.myVal} | |
</div> | |
} | |
const HOC = <T>(Comp: Class<React.Component<any, { myVal: T}, any>>) => | |
({xs}: {xs: Array<T>}) => | |
<div> | |
{xs.forEach(x => <Comp myVal={x} />)} | |
</div> | |
const ListComponent = HOC(InnerComponent) | |
const ListOfValues = [1,2,3] | |
ReactDom.render(<ListComponent xs={ListOfValues} />, document.getElementById('test')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Error given by flow: