Closed GuillaumeCisco closed 6 years ago
Ok just found something even more interesting, I forgot something in my precedent snippet. The correct one is:
import React from 'react';
import {connect} from 'react-redux';
import Link from 'redux-first-router-link';
// import Link from './Link';
//
const Component = () =>
<h1>component</h1>;
const Routes = ({location}) => (
<div>
<Component/>
<Component/>
<Link to={{type: 'HOME'}}>test</Link>
<Component/>
<Component/>
</div>);
const mapStateToProps = ({location}, ownProps) => ({location, ...ownProps});
export default connect(mapStateToProps)(Routes);
This does not work as explained just above. But If I simply replace:
export default connect(mapStateToProps)(Routes);
by
export default Routes;
It does work well. Looks like I have a conflict with the connect part of the redux-first-router-link, which use in its source code:
import { connect } from 'react-redux'
import type { Store } from 'redux'
import type { Connector } from 'react-redux'
...
const connector: Connector<OwnProps, Props> = connect()
// $FlowIgnore
export default connector(Link)
Any ideas on this issue?
Ok, after some tweaking in the redux-first-router-link code, I discovered that simply replacing in the dist/Link.js
file:
var connector = (0, _reactRedux.connect)();
// $FlowIgnore
exports.default = connector(Link);
by
exports.default = Link
make the Link component works correctly with react-hot-loader.
Why do we need to connect to redux the Link
component in the first place?
Ok I just found out the problem.
I'm using the autodll-webpack-plugin
and configured it like:
entry: {
reactVendors: [
'react',
'react-dom',
'react-emotion',
'emotion',
'react-redux',
'react-tap-event-plugin',
],
reduxVendors: [
'redux',
'redux-actions',
'redux-first-router',
'redux-reducers-injector',
'redux-saga',
'redux-sagas-injector',
],
commonVendors: [
'fastclick',
'history',
'react-helmet',
'recompose',
],
},
removing the react-redux
entry, implicitly from the dll generated js files makes it work.
I still don't understand why, but there is clearly something weird with the way react-redux is generated and used.
If someone has an idea and undesrtand why.
PS: I found out the solution, when simply importing the generated redux-first-router-link
in my project and see it working...
Lost 2 days on this.
Hey there, after a lot of research, I finally know what was the real guilty plugin:
new webpack.optimize.ModuleConcatenationPlugin()
Simply removing this plugin from my configuration made everything works correctly, with react-redux
or redux-first-router-link
not loaded in the dll list.
Hope it will help a lot of fellows ;)
Hey there, I'm experiencing a very very weird issue with the
Link
component and react-hot loader. I clearly don't know if this is an issue withredux-first-router-link
or withreact-hot-loader
, but it looks like more withredux-first-router-link
as I experience this issue ONLY with theLink
component.Issue : Everything before a
<Link>
declaration hot reloads correctly, everything after does not. Like if when meeting a<Link/>
component, the hot reload stop refreshing my components, but it displays correctly in the console devtools part the components that should have been updated. Moreover, if I inspect my mapped file in the devtools, I can see correctly the file is updated, but nothing happen on the main window. It really really surprised me and I think I still don't know where the problem come from.So as a solution,I wrote my own version of the
Link
component to debug it as I'm not fluent withflow
.So my version of
Link
looks like:handlePress.js
:As you can see, I don't use the
store
andselectLocationState
for getting the location, but I connect my newLink
to redux for getting it. Surprisingly, react-hot-loader works very well with this version. Which suprises me even more, as I clearly do not understand why the flow version breaks... the flow.Does someone ever experienced this issue? I'm using :
I test this issue with the following snippet:
When I change the text inside the
h1
, only the first two components are updated, not the two last. If I change the text in theLink
component, it is not updated too.Don't hesitate to ask for more information. Thanks