Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Enhancements in routing - Closes #499 #509

Merged
merged 8 commits into from
Jul 26, 2017
Merged

Enhancements in routing - Closes #499 #509

merged 8 commits into from
Jul 26, 2017

Conversation

alepop
Copy link
Contributor

@alepop alepop commented Jul 25, 2017

  • Added <PrivateRoute /> component.
  • Added babel stage-3
  • Fixed Metronome.init(). Moved it from App component.
  • Rewrite App component tests. They are not cover all cases because it is hard to test root component with many dependencies (Provider, Router)
    close Enhancements in routing #499

Copy link
Contributor

@slaweet slaweet left a comment

Choose a reason for hiding this comment

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

Good job @alepop
Couple minor comments below.

const App = () => (
<section className={styles['body-wrapper']}>
<Header />
<Link to='/transactions'>Transactions</Link>
Copy link
Contributor

Choose a reason for hiding this comment

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

these links should be in src/components/defaultLayout/index.js. They will be replaced by the tabs in #505

});
});
});
describe.skip('allow to render private components after logged in', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the skip or add a comment on why it needs to be skipped

@@ -70,7 +70,7 @@ module.exports = (env) => {
exclude: /node_modules/,
loader: 'babel-loader',
options: {
presets: ['es2015', 'react'],
presets: ['es2015', 'react', 'stage-3'],
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you use stage-3 for? I tried to read some basics about what it is, but I cannot find what new features you use.

Copy link
Contributor

Choose a reason for hiding this comment

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

Now I see it is because of { component: Component, ...rest }

const DefaultLayout = ({ component: Component, ...rest }) => (
<PrivateRoute {...rest} component={ matchProps => (
<main>
<Account />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Links component was moved on @slaweet request. I think that the performance change here is negligible especially if you will move the logic from account component and keep it dumb and allow only render the passed props. I do not know how the app will be looked after rebranding, and I think that the layout can help combine some components for differents views.
If you think that is a bad solution than I can return the nested route.

const DefaultLayout = ({ component: Component, ...rest }) => (
<PrivateRoute {...rest} component={ matchProps => (
<main>
<Account />
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed you render Account component and Link components every time changing the route, I think rending them once will help improving performance. to do so, I’d suggest find a way to keep those components mounted once or adapting unit tests. nested routes are used in many apps. there should be some other applications facing this situation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yasharAyari fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

good job. thank you.

const Public = () => <h1>Public</h1>;
const Private = () => <h1>Private</h1>;

describe('<PrivateRouteRender />', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use just PrivateRouteRender to make it consistent with other Components' describes

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancements in routing
4 participants