Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Commit

Permalink
Fixed: navigation now offers a proper scroll behavior.
Browse files Browse the repository at this point in the history
Not more weird page updates.

Closes #285
  • Loading branch information
MoOx committed Jun 12, 2016
1 parent 46e4ac1 commit 1d9711c
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## HEAD

- Fixed: navigation now offers a proper scroll behavior.
Not more weird page updates.
([#285](https://github.com/MoOx/phenomic/issues/285) - @MoOx)

### Boilerplate

- Added: ``PageLoading`` now use "Loading..." has a title
Expand Down
4 changes: 4 additions & 0 deletions interfaces/external-modules/react-router-scroll.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module "react-router-scroll" {
declare var exports:
(shouldUpdateScroll?: () => boolean | Array<number>) => Function;
}
36 changes: 36 additions & 0 deletions interfaces/external-modules/react-router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
declare module "react-router" {
declare interface ReactRouter {
IndexRoute: React.Component;
Link: React.Component;
Redirect: React.Component;
IndexRedirect: React.Component;
Route: React.Component;
Router: React.Component;
browserHistory: any;
useRouterHistory:
(historyFactory: Function) => (options: ?Object) => Object;
match: Function;
RouterContext: React.Component;
createRoutes: (routes: React$Element) => Array<Object>;
formatPattern: (pattern: string, params: Object) => string;
applyRouterMiddleware: Function;
}
declare var exports: ReactRouter;
}

declare module "react-router/lib/PatternUtils" {
declare var exports: any;
}

declare module "history/lib/createBrowserHistory" {
declare var exports: any;
}

export type ReactRouterProps = {
history: Object,
location: Object,
params: Object,
route: Object,
routeParams: Object,
routes: Array<Object>,
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"opn": "^4.0.2",
"pify": "^2.3.0",
"portfinder": "^1.0.2",
"react-router-scroll": "^0.2.0",
"redbox-react": "^1.2.2",
"remark": "^4.1.1",
"remark-autolink-headings": "^3.0.0",
Expand Down
9 changes: 7 additions & 2 deletions src/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
// App
import React from "react"
import ReactDOM from "react-dom"
import { Router, useRouterHistory } from "react-router"
import { Router, useRouterHistory, applyRouterMiddleware } from "react-router"
import createBrowserHistory from "history/lib/createBrowserHistory"
import useScroll from "react-router-scroll"
import { Provider as ReduxContextProvider } from "react-redux"

import PhenomicContextProvider from "../ContextProvider"
Expand Down Expand Up @@ -35,7 +36,11 @@ export default function phenomic({
metadata={ metadata }
>
<ReduxContextProvider store={ store }>
<Router history={ browserHistory } routes={ routes } />
<Router
history={ browserHistory }
routes={ routes }
render={ applyRouterMiddleware(useScroll()) }
/>
</ReduxContextProvider>
</PhenomicContextProvider>,
document.getElementById("phenomic")
Expand Down

0 comments on commit 1d9711c

Please sign in to comment.