Last active
September 27, 2019 06:46
-
-
Save SharpCoder/3ccc39ac8396c86dfc676831364345bc to your computer and use it in GitHub 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, { PureComponent, useState } from 'react'; | |
| import SlideNavigator from './slider/slideNavigator'; | |
| const MyView = ({ className, navigateTo }) => { | |
| return (<h1 style={{backgroundColor: "blue"}} className={className} onClick={() => { navigateTo("view2")} }>Hello, world!</h1>); | |
| }; | |
| const MyOtherView = ({ className, navigateBack, navigateTo }) => { | |
| const [navs, setNavs] = useState(0); | |
| return (<h1 style={{backgroundColor: "orange"}} className={className} onClick={() => { | |
| if (navs === 0) { | |
| setNavs(1); | |
| navigateTo("view3"); | |
| } else { | |
| setNavs(0); | |
| navigateBack(); | |
| } | |
| }}>The stars are lovely today!</h1>); | |
| }; | |
| const MyOtherOtherView = ({ className, navigateBack }) => { | |
| return ( | |
| <h1 style={{backgroundColor: "pink"}} className={className} onClick={navigateBack}> | |
| And so is Thorbrand! | |
| </h1> | |
| ); | |
| } | |
| export default class App extends PureComponent { | |
| render() { | |
| return ( | |
| <SlideNavigator defaultName="view1"> | |
| <MyView name="view1" key="1" /> | |
| <MyOtherView name="view2" key="2" /> | |
| <MyOtherOtherView name="view3" key="3" /> | |
| </SlideNavigator> | |
| ); | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment