Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Touchable = (Component, handler) => {
- const T = ({props, children}) => {
- const Instance = React.createElement(
- Component,
- {
- ...props,
- onTouchStart: (e) => handler.touchStart(e),
- /*more listeners*/
- }, children);
- }
- return T;
- }
- const Button = ({props, children}) => <div>…</div>;
- export default Touchable(Button, {touchStart: () => {}});
- <Button>Hallo</Button>
- <Button onTouchStart={…}>
- <div>…</div>
- </Button>
- <Button>
- <div onTouchStart={…}>…</div>
- </Button>
Add Comment
Please, Sign In to add comment