-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Redux: store state and reducers #384
Comments
I'd suggest not copying GraphQL state into a new part of the store unless you really need to. If you need to reformat arguments, you can easily just use a new intermediate component: funcition MyComponentReformatted(props) {
return <MyComponent myProp={prop.data.thing} />
} |
What if need some computed fields? Putting that logic to a component doesn't feel right. I thought I should be using reducers. But in reducers I don't have access to GraphGL data. Do I? |
Can I just handle |
You can always use |
This issue interests me. We use a form library which is entirely stateless: it uses the Currently, we're using a Redux store with keys We'd like to be able to extract data out of the Apollo query response, and populate the Right now, we're using components to deal with this, which feels a level or two too far down. Here's how we're managing to do it:
All of the following applies to
It would be nice if This would (might?) require some way to intercept query responses and place them in different parts of the redux tree. It seems that this approach isn't really what |
Hmm, personally I would have actually used the approach that you just described. But I can understand that it's not appealing to everyone. How about dispatching an action inside your By the way, |
You can now use the |
I have same question. We know that is redux if you want to apply some additional logic on your data response in state before you pass it to component you can do it in selector. But since with apollo you connect data response directly to component I don't know where to apply this logic, here we do not have selectors. so we know store can look like this if we use redux and apollo
So for redux you would select piece of state and pass it mapStateToProps and before you pass it you can apply some business logic to selected peace of state, but how to apply it to apollo peace of state? |
I believe you can pass a |
That is one way but I prefer to keep data manipulation in data layer not to do it in UI layer. |
I also have the problem that I have a huge amount of data which should be transformed on the client only in order to render a svg graphic. I do not know where I would have to start since I want this all be handled on the data layer. It got really messy be combining it with the components in Ember.js, so we are searching for a nice alternative and we are interested in using react, redux + apollo-client to solve these problems |
As far as I read, there's no way to pass a graphql response through reducers. I've looked into "apollo" state object but it doesn't seem to provide the same data we have in component's properties (in mapQueriesToProperties).
I'm new to redux, but should we be able to preprocess server's response before passing them on to React components?
I've tried dispatching data in React component but it doesn't feel right.
Is there a way to move data from queries to store?
The text was updated successfully, but these errors were encountered: