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

Using react-redux connect deep force update does not work #2

Open
haneev opened this issue Jul 22, 2016 · 2 comments
Open

Using react-redux connect deep force update does not work #2

haneev opened this issue Jul 22, 2016 · 2 comments

Comments

@haneev
Copy link

haneev commented Jul 22, 2016

forceUpdate is ignored by react-redux connect. Because internally a renderedElementis stored and forceUpdate does not reset this element, leading to rendering an possibly 'old' component. A fix could be like adding this code to deepForceUpdate. Or update react redux connect to handle forceUpdate.

    traverseRenderedChildren(node, internalInstance => {
        const instance = internalInstance._instance;
        if (instance && instance.renderedElement) {
            instance.renderedElement = null;
        }
    });
@gregberge
Copy link
Collaborator

I think it is possible to trick it using #6 isn't it?

@wmertens
Copy link

wmertens commented Feb 6, 2018

I think I'm making it work by using

					deepForceUpdate(
						this.childRef,
						// Deep react stuff - the stateNode is probably from react-hot-loader
						instance => {
							const n = instance && (instance.stateNode || instance)
							return n && (n.context && n.context.i18n)
						},
						instance => {
							const n = instance && (instance.stateNode || instance)
							if (n && n.updater && n.updater.enqueueForceUpdate)
								n.updater.enqueueForceUpdate(n)
						}
					),

i18n is the context I'm updating, the stateNode is probably from react-standin, and the enqueueForceUpdate is some voodoo API from somewhere, possibly React?.

This is using v4 beta btw.

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

No branches or pull requests

3 participants