Context differs problem
- Langage dominant
- JavaScript
- Étoiles
- 1.7k
- Forks
- 109
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
Hello, first of all sorry for my bad english:) I've made code example, which can help you reproduce this error.
_routes.jsx_
``` js
import React from 'react';
import { Route, DefaultRoute } from 'react-router';
import AppHandler from './handlers/AppHandler';
import LandingHandler from './handlers/LandingHandler';
export default (
);
```
_index.jsx_
``` js
import React from 'react';
import {
create as createRouter,
HistoryLocation,
HashLocation
} from 'react-router';
import routes from './routes';
import Flux from './Flux';
import FluxComponent from 'flummox/component';
const flux = new Flux();
const location = HashLocation;
const router = createRouter({ routes, location });
router.run((Handler, state) => {
React.render(
,
document.getElementById('root')
);
});
```
_AppHandler.jsx_ (Just a simple wrapper for now)
``` js
import React, { Component } from 'react';
import { RouteHandler } from 'react-router';
export default class AppHandler {
render() {
return ;
}
}
```
_LandingHandler.jsx_
``` js
import React, { Component } from 'react';
import connectToStores from 'flummox/connect';
class LandingHandler extends Component {
render() {
return {`${this.props.userLogged}`};
}
}
export default connectToStores(LandingHandler, {
auth: (store) => ({
userLogged: store.state.userLogged
})
});
```
When I started app, and went on default app route, I've got a warning message:
**Warning: owner-based and parent-based contexts differ (values: `undefined` vs `[object Object]`) for key (flux) while mounting ConnectedComponent (see: http://fb.me/react-context-by-parent)**
This message has gone when I removed FluxComponent in index.jsx, and pass flux instance to Handler instantly.
_index.jsx_
``` js
router.run((Handler, state) => {
React.render(
,
document.getElementById('root')
);
});
```
In both cases routing and Flummox lifecycle functionality work fine. Hopefully you can reproduce this bug. Thanks
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.