Skip to content

willTransitionFrom is never triggered #2

@liouh

Description

@liouh

I used this package to replace react-proxy-loader. While willTransitionTo is working great, willTransitionFrom never triggers.

The "component" being sent to willTransitionFrom appears to be the proxy component, and thus always fails the component.willTransitionFrom check:

https://github.com/odysseyscience/react-router-proxy-loader/blob/master/index.js#L34

'        willTransitionFrom: function(transition, component, callback) {',
'            if (component && component.willTransitionFrom) {',
'                component.willTransitionFrom(transition, component, callback);',

I added component = component.state.component; to the first line of the function above, and it does trigger willTransitionFrom on the dynamically loaded component. However, since component.state.component is the React class definition, and not the instance, I don't have access to the component state as documented by react-router below:

willTransitionFrom(transition, component, callback)

Called when an active route is being transitioned out giving you an opportunity to abort the transition. The component is the current component, you'll probably need it to check its state to decide if you want to allow the transition (like form fields).

Is there a way to make willTransitionFrom trigger with the proper component instance?

Any guidance would be appreciated. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions