Skip to content

Instantly share code, notes, and snippets.

@matiasfha
Created May 13, 2018 21:16
Show Gist options
  • Save matiasfha/f4f11a900a55bd3d3976f0e2a97e7340 to your computer and use it in GitHub Desktop.
Save matiasfha/f4f11a900a55bd3d3976f0e2a97e7340 to your computer and use it in GitHub Desktop.
Flow union type
/* @flow */
import * as React from 'react'
type BaseMenuPropsT = {
icon: string | { img: string, ticker: number },
label?: string
}
type RenderT = { render: () => React.Node }
type ChildrenT = { children: () => React.Node }
type DataT = { data: Object }
type MenuPropsT = BaseMenuPropsT & (RenderT | ChildrenT | DataT)
const Menu = (props: MenuPropsT) => (
<div>`This are the props ${JSON.stringify(props)}`</div>
)
const App = () =>
<Menu icon="string" data={{}} />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment