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

Is not working with react-redux 6 #9

Closed
rcanessa89 opened this issue Mar 1, 2019 · 6 comments
Closed

Is not working with react-redux 6 #9

rcanessa89 opened this issue Mar 1, 2019 · 6 comments

Comments

@rcanessa89
Copy link

rcanessa89 commented Mar 1, 2019

Is not working with react redux 6.0.1, the problem is the store value in the context, is coming undefined, looks like the current version of "ui-router/redux" is using the legacy React context API.

I builded this solution for my project but the context API should be change it for future versions of React.

import store from '@store';
import { pushStateLocationPlugin, UIView } from '@uirouter/react';
import { ConnectedUIRouter } from '@uirouter/redux/lib/react';
import * as PropTypes from 'prop-types';
import * as React from 'react';
import config from './config';
import { router } from './index';
import states from './states';

const plugins = [
  pushStateLocationPlugin
];

export default class AppRouter extends React.Component<any> {
  public static childContextTypes = {
    store: PropTypes.object
  };

  public getChildContext() {
    return {
      store,
    };
  }

  public render() {
    return (
      <ConnectedUIRouter
        router={router}
        plugins={plugins}
        states={states}
        config={config}
      >
        <UIView />
      </ConnectedUIRouter>
    );
  }
}

@DamianOsipiuk
Copy link

DamianOsipiuk commented Apr 16, 2019

@elboman +1 for this. Two solutions:

  1. Move to the new context API (breaking change requiring version bump, not ideal)
  2. Give possibility to provide store as a prop. (this solution is actually backwards compatible).

Currently have to patch it up locally.
https://react-redux.js.org/using-react-redux/accessing-store

@elboman
Copy link
Member

elboman commented Apr 19, 2019

Hey, thanks for filing the issue.

I think it's fair to go with solution number one, as the current version is 0.1.x and we were expecting breaking changes anyway.

React hooks are here to stay, and I assume, given the super simple upgrade path for react-redux, most users will be using the latest version anyway.

I'm about to push an update that converts ConnectedUIRouter to a function component with hooks, and that supports the newer version of Redux.

@elboman
Copy link
Member

elboman commented Apr 19, 2019

Hey, I've put up #10 to tackle this, what do you think?

@marcellino-ornelas
Copy link

marcellino-ornelas commented Sep 4, 2019

@elboman any updates on this? Having the same issue

@DamianOsipiuk
Copy link

@elboman Can you say when this could be released? It would be nice to have the original package instead of a forked one.

@christopherthielen
Copy link
Member

https://github.com/ui-router/redux/releases/tag/1.0.0

I don't actually use this project, but I released @elboman 's PR as 1.0.0.
let me know if this works for ya'll or not.

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

5 participants