Skip to content

Instantly share code, notes, and snippets.

@danakt
Last active February 11, 2019 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danakt/662a32421d73f42f696f01ab0383cafd to your computer and use it in GitHub Desktop.
Save danakt/662a32421d73f42f696f01ab0383cafd to your computer and use it in GitHub Desktop.
Creates react container with render props pattern
const createContainer = function<Props = {}, Data = {}, Actions = {}>(callback: (props: Props) => [Data, Actions]) {
return (props: Props & { children: (data: Data, actions: Actions) => React.ReactNode }) => (
<React.Fragment>{props.children(...callback(props))}</React.Fragment>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment