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

feat(loadAsyncData): check window object for server side #23

Conversation

evenchange4
Copy link

Try to solve the PR at #872

@sars
Copy link
Member

sars commented Feb 1, 2016

@evenchange4 , to be honest, i didn't catch what this PR solves.
this code is never called on server side...

@evenchange4
Copy link
Author

It solves the same thing what #872 does, but checking __SERVER__ inside the redux-async-connect.
I mean the server side render.

cc @sars

@sars
Copy link
Member

sars commented Feb 12, 2016

@evenchange4, take a look please:
https://github.com/Rezonans/redux-async-connect/tree/v1

there is new interface for @asyncConnect decorator in this version.

Now you can use it like:

@asyncConnect([
  {key: 'lunch', promise: ({params, helpers}) => helpers.client.get('/lunches/' + params.lunchId), group: 'smth'}
])

and then in your client.js:

const component = (
  <Router render={(props) =>
        <ReduxAsyncConnect {...props} filter={item => item.group === 'smth'} helpers={{client}} />
      } history={browserHistory}>
    {getRoutes(store, client)}
  </Router>
);

and server.js:

loadOnServer({...renderProps, store, helpers: {client}}).then(() => {
  // ...
}

Does it works for you?

@evenchange4
Copy link
Author

okay works for me
@sars thanks!
close it

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

Successfully merging this pull request may close these issues.

2 participants