Skip to content

Instantly share code, notes, and snippets.

@icyJoseph
Last active June 15, 2018 06:28
Show Gist options
  • Save icyJoseph/b214110365586fe35a91e2bf0bb07aaa to your computer and use it in GitHub Desktop.
Save icyJoseph/b214110365586fe35a91e2bf0bb07aaa to your computer and use it in GitHub Desktop.
Responsive content passing props
import React from 'react';
import Media from 'react-media';
const Mobile = ({ title }) => <div>{title} Mobile</div>;
const Desktop = ({title}) => <div>{title} Desktop</div>;
const Responsive = ({ ...props }) => (
<Media query={{ maxWidth: 1023 }}>
{matches => (matches ? <Mobile {...props} /> : <Desktop {...props} />)}
</Media>
);
export default Responsive;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment