Last active
February 13, 2019 08:46
-
-
Save scink/689da03059c5a3eaf5fcb258db176dda 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
export type Item = { | |
name: string; | |
value: string; | |
}; | |
export type FooProps = { | |
data: RemoteData<Error, Item[]>; | |
}; | |
const RenderRemoteData = getRenderRemoteData({ | |
DataStateFailure: () => <span>Failure</span>, | |
DataStateNoData: () => <span>NoData</span>, | |
DataStatePending: () => <span>Pending</span>, | |
}); | |
export class Foo extends PureComponent<FooProps> { | |
public render() { | |
const { data } = this.props; | |
// this option has an error | |
return <RenderRemoteData data={data} success={this.renderSuccess} noData={isEmpty} />; | |
// but this one does not | |
// return <RenderRemoteData data={data} success={this.renderSuccess} noData={data => isEmpty(data)} />; | |
} | |
private renderSuccess = (data: Item[]) => ( | |
<Fragment> | |
{data.map(item => ( | |
<span>{item.name}</span> | |
))} | |
</Fragment> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment