-
Notifications
You must be signed in to change notification settings - Fork 586
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
Using redux components within renderer #146
Comments
@kromit Sorry, I don't quite understand. Could you please create a Codepen that demonstrates the issue? |
This is not that complicated.
The I've fixed this for me by using |
@kromit Do you have a suggestion how to improve Autosuggest for this use case? |
I have no idea. I've looked into redux docs, but I've found nothing useful to fix this problem. We could evtl talk to @Gaeron about this since I am not sure if this is working as intended. |
@kromit Here are my initial thoughts:
// AutosuggestContainer.js
import { createProvider } from 'react-redux';
const Provider = createProvider({ contextName: 'autosuggestStore' });
... Then, we could do: // Autosuggest.js
import { connect } from 'react-redux';
import { mapContextWith } from 'react-context-utils';
...
export default mapContextWith(context => ({ store: context.autosuggestStore }))(connect(...)(Autosuggest)); @gaearon Would be keen to hear your thoughts on how to address this issue. @kromit Is |
Don't use Provider in a library, and pass store as a prop to the connected component instead. Connect detects store in props as a fallback. |
Thanks @gaearon, much simpler! |
This is fixed in 3.7.3 now. |
@moroshko I am not sure if the current solution will work for multiple autosuggest inputs when they are using the same store. I've not tested this, but should not every autosuggest input use a dedicated state path like based on its id or something? |
The store is created in the constructor for every instance so this shouldn’t be an issue. It’s an implementation detail. |
I think @kromit is right. If we pass the store to the component as a prop then every component uses the same store so the reducer needs to maintain state for every instance of the component. |
Just a note that |
Since the autosuggest uses its own redux store, the following use case is not possible:
The
I18n
Component uses a redux store, where the global translation messages are stored. But when the renderer is called, there is only the store from autosuggest.The text was updated successfully, but these errors were encountered: