forked from jossmac/react-images
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
also started the react-router example
- Loading branch information
Showing
7 changed files
with
117 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// @flow | ||
|
||
import React, { type ComponentType } from 'react'; | ||
import { Route } from 'react-router-dom'; | ||
import { type ProviderProps } from './ImageProvider'; | ||
|
||
type Props = ProviderProps & { | ||
component: ComponentType<*>, | ||
exact?: boolean, | ||
path: string, | ||
}; | ||
|
||
const ImageRoute = (props: Props) => { | ||
const { component: Component, images, isLoading, ...rest } = props; | ||
|
||
return ( | ||
<Route | ||
{...rest} | ||
children={routeProps => ( | ||
<Component images={images} isLoading={isLoading} {...routeProps} /> | ||
)} | ||
/> | ||
); | ||
}; | ||
|
||
export default ImageRoute; |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// @flow | ||
// @jsx glam | ||
import glam from 'glam'; | ||
import React, { Component } from 'react'; | ||
|
||
import Carousel from '../../src/components'; | ||
import { type ProviderProps } from '../ImageProvider'; | ||
|
||
export default class ReactRouter extends Component<ProviderProps> { | ||
static defaultProps = { | ||
activeIndices: [0], | ||
}; | ||
handleViewChange = activeIndices => { | ||
const { history, location } = this.props; | ||
history.push(`${activeIndices}`); | ||
console.log('activeIndices', activeIndices); | ||
}; | ||
render() { | ||
const { activeIndices, images, isLoading } = this.props; | ||
|
||
console.log('router example', this.props); | ||
|
||
return ( | ||
<div> | ||
<h1>React Router Example</h1> | ||
{!isLoading ? ( | ||
<Carousel | ||
frameProps={{ autoSize: 'height' }} | ||
trackProps={{ | ||
infinite: true, | ||
currentView: activeIndices, | ||
onViewChange: this.handleViewChange, | ||
}} | ||
views={images} | ||
components={{ Header: null }} | ||
/> | ||
) : null} | ||
</div> | ||
); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { default as Home } from './Home'; | ||
export { default as NoMatch } from './NoMatch'; | ||
export { default as ReactRouter } from './ReactRouter'; |
This file contains 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