Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration to redux simple router and async-props #833

Merged
merged 10 commits into from
Feb 15, 2016
Merged

Conversation

sars
Copy link
Contributor

@sars sars commented Jan 15, 2016

No description provided.

@sars
Copy link
Contributor Author

sars commented Jan 15, 2016

@quicksnap
Copy link
Collaborator

Looks like the build is failing..

@sars
Copy link
Contributor Author

sars commented Jan 15, 2016

@quicksnap Do you mean npm run build ?
It works fine for me...

@quicksnap
Copy link
Collaborator

The Travis builds are failing, that is. They're at the bottom of this comment thread.

@sars
Copy link
Contributor Author

sars commented Jan 15, 2016

@quicksnap , yeah, I'm going to fix it after ryanflorence/async-props#42 will be merged

@bdefore
Copy link
Collaborator

bdefore commented Jan 16, 2016

@sars that's a nice helper the resolver addition. i'm wondering if they'll be amenable to merging it.

@bdefore
Copy link
Collaborator

bdefore commented Jan 16, 2016

just had a look through this PR and it provides a nice lean update for this project to react-router 2.0 and replacing custom serverside fetching with something more tightly integrated with ongoing development there. it accomplishes much of what universal-redux does (#759) apart from updating to Babel 6, which has another proposal (#778).

i still think there's value in depending on universal-redux to easier rise with the tide of future developments and provide a configurable base for those using this as a starting point, but that conversation can be independent of merging this one. in fact, this aligns RRUHE closer to UR, and would ease the migration path.

@jakegibson
Copy link

line 15 of src/server.js has a reference to redux-router that needs to be removed for it to build

@@ -107,12 +108,11 @@
"react-helmet": "^2.2.0",
"react-inline-css": "^2.0.0",
"react-redux": "^4.0.0",
"react-router": "1.0.3",
"react-router": "2.0.0-rc5",
"react-router-bootstrap": "^0.19.3",

Choose a reason for hiding this comment

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

This needs to be upgraded to 0.20.x

From react-router-bootstrap README.md:

Note: Releases from v0.20.0 onward only support React Router v2.x....

@andresgutgon
Copy link

I'm trying to port this PR to my code.
When doing npm install I was having problems with post install script of async-props. Opened an issue in their repo:
ryanflorence/async-props#46

To be able to run npm install I installed babel globally npm install babel@x.x.x -g

@bdefore
Copy link
Collaborator

bdefore commented Jan 17, 2016

I had a PR out to fix this ryanflorence/async-props#36

But at this point I think they want to stay out of the build tool jungle. I ended up pulling async-props source directly into universal-redux in order to support it.

@sars
Copy link
Contributor Author

sars commented Jan 18, 2016

Have a look, guys, please
#531 (comment)
It should make your life much easier...

@erikras, @bdefore If you want, I can create for your projects...

@bdefore
Copy link
Collaborator

bdefore commented Jan 18, 2016

@sars that would be great, thanks!

@sars
Copy link
Contributor Author

sars commented Jan 20, 2016

@quicksnap , @erikras , going to redo this pr with redux-asyc-connect today. it should be good

@sars
Copy link
Contributor Author

sars commented Jan 20, 2016

@jakegibson , thank you for comments

line 15 of src/server.js has a reference to redux-router that needs to be removed for it to build

done

This needs to be upgraded to 0.20.x

done

🔥 remove this line

done

@quicksnap , @erikras , please, have a look.
I believe this PR really simplify this example.

I did not use all features from redux-async-connect here to keep diff as small as possible...
but i'm going to add some examples in next PR

@andresgutgon
Copy link

💪 waiting for it. I'll try it on my project

@sars
Copy link
Contributor Author

sars commented Jan 20, 2016

there is some problem with test:

20 01 2016 11:22:09.969:ERROR [karma]: { [Error: no such file or directory]
  code: 'ENOENT',
  errno: 34,
  message: 'no such file or directory',
  path: '/_karma_webpack_/tests.webpack.js' }
Error: no such file or directory
    at MemoryFileSystem.readFileSync (/Users/rodik/RubymineProjects/react-redux-universal-hot-example/node_modules/memory-fs/lib/MemoryFileSystem.js:114:10)
    at MemoryFileSystem.readFile (/Users/rodik/RubymineProjects/react-redux-universal-hot-example/node_modules/memory-fs/lib/MemoryFileSystem.js:297:21)
    at doRead (/Users/rodik/RubymineProjects/react-redux-universal-hot-example/node_modules/karma-webpack/index.js:156:26)
    at Plugin.readFile (/Users/rodik/RubymineProjects/react-redux-universal-hot-example/node_modules/karma-webpack/index.js:160:3)

but i don't see how this is related to PR
and cannot understand hot to fix it....

@lemonCMS
Copy link
Contributor

@sars, great PR, just one question. When the widget fails to load (33%), the widget page keeps waiting for a response and will never load. Do you have any solution for that?

@sars
Copy link
Contributor Author

sars commented Jan 20, 2016

Oh yes, i fixed tests :)

@sars
Copy link
Contributor Author

sars commented Jan 20, 2016

@lemonCMS fixed in async connect 0.1.4
fixed in this PR too
thanks

@erikras
Copy link
Owner

erikras commented Jan 20, 2016

This is gorgeous. 👍 Great work, @sars!

@erikras
Copy link
Owner

erikras commented Jan 20, 2016

I noticed you removed scrollableHistory. Does this not have the problem that was solving?

@sars
Copy link
Contributor Author

sars commented Jan 20, 2016

@erikras thanks for comments

I don't completely understand what scroll-behavior lib does...
But anyway - it looks like it isn't compatible with react-router 2:

taion/scroll-behavior#28

@lemonCMS
Copy link
Contributor

@sars when the route changes depending on witch scroll-behavior you have implemented, the page scroll to the top. Without this, the scroll position stay's the same.

But indeed, not yet compatible.

Better initialization of react router redux on server-side (with original url)
@sars
Copy link
Contributor Author

sars commented Feb 11, 2016

@quicksnap Rebased
About deferred data fetching - I'm working on 1.0.0 version now. I'm going to use redial approach, i think.

@FoxxMD
Copy link
Contributor

FoxxMD commented Feb 11, 2016

👍

@mmahalwy
Copy link

@sars sorry to do this to you, so close! I found a bug that is due to removing this line: https://github.com/erikras/react-redux-universal-hot-example/pull/833/files#diff-e6a5b42b2f7a26c840607370aed5301aL97

Now query params are not set on the location. I don't know if that's a problem with us here or a problem with react-router-redux not picking up on the location.

@sars
Copy link
Contributor Author

sars commented Feb 11, 2016

@mmahalwy
Copy link

@sars hmm weird, I must have had your old changes. You're right! Works perfectly :)

@sars
Copy link
Contributor Author

sars commented Feb 13, 2016

Guys, take a look please at new version of redux-async-connect

brocoders/redux-async-connect#16 (comment)

Documentation is in progress... But it solves several significant issues: router in params, ability to define something like deferred props, etc.

several modules updated
@sars
Copy link
Contributor Author

sars commented Feb 13, 2016

scroll-behavior works now!


export default function createStore(reduxReactRouter, getRoutes, createHistory, client, data) {
const middleware = [createMiddleware(client), transitionMiddleware];
export default function createStore(getRoutes, history, client, data) {
Copy link

Choose a reason for hiding this comment

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

getRoutes is unnecessary...

@sars
Copy link
Contributor Author

sars commented Feb 14, 2016

@farrrr
thanks, fixed

@sars
Copy link
Contributor Author

sars commented Feb 14, 2016

@quicksnap , I think it looks quite stable for merging to master.... what do you think?

@gabriel-miranda
Copy link

I want this so bad in master branch

@quicksnap
Copy link
Collaborator

It feels stable to me. I've been using it in our product and haven't had much problems. Here goes nothing!

quicksnap added a commit that referenced this pull request Feb 15, 2016
Migration to redux simple router and async-props
@quicksnap quicksnap merged commit 5215f66 into erikras:master Feb 15, 2016
@snackycracky
Copy link
Contributor

BAM

Sent from my Tricorder

On 15.02.2016, at 09:23, Dan Schuman notifications@github.com wrote:

Merged #833.


Reply to this email directly or view it on GitHub.

@andresgutgon
Copy link

😱

OMG 👏

@anomaly44
Copy link

this is great, nice work guys! thanks!

@oyeanuj
Copy link

oyeanuj commented Feb 15, 2016

this is great works folks!

would it be possible for someone involved in the PR to write a couple of bullet points as a guide on what has changed conceptually and how (essentially, how to migrate)? I suspect a lot of people who have been using this boilerplate and have done a lot of subsequent work would want to absorb these changes, and quick explanation on the changes would be very helpful!

thanks again everyone involved with it!

@andrewmclagan
Copy link
Collaborator

@oyeanuj Agreed, feel that would help allot of people out.

@janhoogeveen
Copy link

Don't we need to change the requireLogin method in routes.js as well?

const requireLogin = (nextState, replaceState, cb) => {
    function checkAuth() {
      const { auth: { user }} = store.getState();
      if (!user) {
        // oops, not logged in, so can't be here!
        replaceState(null, '/');
      }
      cb();
    }

    if (!isAuthLoaded(store.getState())) {
      store.dispatch(loadAuth()).then(checkAuth);
    } else {
      checkAuth();
    }
  };

to

  const requireLogin = (nextState, replace, cb) => {
    function checkAuth() {
      const { auth: { user }} = store.getState();
      if (!user) {
        // oops, not logged in, so can't be here!
        replace('/');
      }
      cb();
    }

    if (!isAuthLoaded(store.getState())) {
      store.dispatch(loadAuth()).then(checkAuth);
    } else {
      checkAuth();
    }
  };

@FoxxMD
Copy link
Contributor

FoxxMD commented Feb 16, 2016

@oyeanuj +1 for a guide. This looks much cleaner but I need some clear instructions on how to migrate these changes.

@sars
Copy link
Contributor Author

sars commented Feb 16, 2016

Guys, I'll try to create something like migration doc, but to be honest it's not so obvious. If you look at diff from this PR, you find all changes.
I'd like to add some docs and fix existing docs in this project, because some of them became a little bit outdated.
But first it would be great to solve issue with deferred props:
#928
There was such feature in this project and now there isn't
I try to find the most convenient way to solve this and need some feedback...

@oyeanuj
Copy link

oyeanuj commented Feb 29, 2016

@sars Now that #928 is merged, any high-level explanation of changes whenever you get a chance would be super appreciated :) Thanks again for all your work!

@sars
Copy link
Contributor Author

sars commented Feb 29, 2016

@oyeanuj will do shortly

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

Successfully merging this pull request may close these issues.

None yet