Last active
April 6, 2019 05:22
-
-
Save imranismail/7b725d6cd387c3f25dc60f7d00aef615 to your computer and use it in GitHub Desktop.
Adaptive Web Apps
This file contains hidden or 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
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import Service from './service'; | |
const runApp = (App) => | |
ReactDOM.render(<Service.Provider><App /></Service.Provider>, document.getElementById('root')) | |
import('ontouchstart' in window ? './mobile' : './desktop').then((app) => runApp(app)) |
This file contains hidden or 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
import React from 'react'; | |
import Service from './service'; | |
const Desktop = (props) => | |
<Service.Consumer> | |
{service => <h1>Hello {service.user.current.name}, from Desktop</h1>} | |
</Service.Consumer> | |
export default Desktop; |
This file contains hidden or 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
import React from 'react'; | |
const Service = React.createContext({user: {current: {name: "John Doe"}}}); | |
export default Service; |
This file contains hidden or 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
import React from 'react'; | |
import Service from './service'; | |
const Touch = (props) => | |
<Service.Consumer> | |
{service => <h1>Hello {service.user.current.name}, from Touch</h1>} | |
</Service.Consumer> | |
export default Touch; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment