Skip to content

Commit

Permalink
Remove 'observer' from the global App component (#221)
Browse files Browse the repository at this point in the history
Fixes the bug with infinite redirect loop
in 'back' button press.

Inside the Application component creates LoadingBar component
connected to the store.
  • Loading branch information
viktor-yakubiv authored Mar 31, 2020
1 parent a8080fa commit d6b495d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 2 additions & 3 deletions components/application/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'

import { Container, AppBar, SideBar, Main } from '../layout'
import LoadingBar from '../loading-bar'
import LoadingBar from './loading-bar'
import RepositorySelect from './repository-select'
import ActivitySelect from './activity-select'
import Head from './head'
Expand All @@ -15,13 +15,12 @@ const Application = ({
dataProvider,
activity,
isAuthenticated = false,
isLoading = false,
...restProps
}) => (
<>
<Head />
<Container {...restProps}>
{isLoading && <LoadingBar className={styles.loadingBar} />}
<LoadingBar className={styles.loadingBar} />
<AppBar variant={isAuthenticated ? 'internal' : 'public'}>
{isAuthenticated ? (
<>
Expand Down
9 changes: 9 additions & 0 deletions components/application/loading-bar.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react'

import { withGlobalStore } from 'store'
import LoadingBar from 'components/loading-bar'

const LoadingBarController = ({ store, ...passProps }) =>
store.isLoading ? <LoadingBar {...passProps} /> : null

export default withGlobalStore(LoadingBarController)
3 changes: 0 additions & 3 deletions pages/_app/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react'
import NextApp from 'next/app'
import { withRouter } from 'next/router'
import { autorun } from 'mobx'
import { observer } from 'mobx-react'

import '@oacore/design/lib/index.css'

Expand All @@ -26,7 +25,6 @@ process.on('uncaughtException', err => {
Sentry.captureException(err)
})

@observer
class App extends NextApp {
state = {
isAuthorized: false,
Expand Down Expand Up @@ -265,7 +263,6 @@ class App extends NextApp {
dataProvider={store.dataProvider}
activity={store.activity.id}
onClick={this.handleNavigation}
isLoading={store.isLoading}
isAuthenticated
>
<Component {...pageProps} />
Expand Down

1 comment on commit d6b495d

@vercel
Copy link

@vercel vercel bot commented on d6b495d Mar 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.