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

Warnings when using react-redux connect #1049

Closed
oscar-broman opened this issue Aug 16, 2018 · 6 comments
Closed

Warnings when using react-redux connect #1049

oscar-broman opened this issue Aug 16, 2018 · 6 comments

Comments

@oscar-broman
Copy link

oscar-broman commented Aug 16, 2018

Description

When debug logging is enabled, warnings are generated when reloading a component that uses both hot and connect.

Environment

React Hot Loader version: 4.3.4

Run these commands in the project folder and fill in their results:

  1. node -v: v10.8.0
  2. npm -v: 6.3.0

Then, specify:

  1. Operating system: macOS 10.13.6
  2. Browser and version: Chrome 68.0.3440.106

Reproducible Demo

index.js

import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { setConfig } from 'react-hot-loader';
import { createStore } from 'redux';

import Test from './Test';

setConfig({ logLevel: 'debug' });

const store = createStore((state = {}) => state);

// Wrap the rendering in a function:
ReactDOM.render(
  <Provider store={store}>
    <Test />
  </Provider>,
  document.getElementById('root')
);

Test.js

import React, { Component } from 'react';
import { connect } from 'react-redux';
import { hot } from 'react-hot-loader';

class Test extends Component {
  render() {
    return <div>Test</div>;
  }
}

export default hot(module)(connect()(Test));

Console output after performing change

React Hot Loader:, Non-controlled class Connect(Test) contains a new native or bound function  setWrappedInstance ƒ setWrappedInstance(ref) {
        this.wrappedInstance = ref;
      } . Unable to reproduce

Way to do it that does not cause this warning

// Change bottom of Test.js
export default hot(module)(Test);

// Create TestRedux.js and use it in place of Test.js
import { connect } from 'react-redux';
import { hot } from 'react-hot-loader';

import Test from './Test';

export default connect()(Test);
@theKashey
Copy link
Collaborator

That's not a bug - that's a feature of RHL v4.
RHL's babel plugin was not extended to your node_modules directory, thus RHL has no power upon classes defined there.

Meanwhile - everything is working, RHL just reporting that it could not do some replacements, but they are not needed for redux.

You can ignore this message(change logLevel), or remove it using cold API (but I have another issue related to it, so wait a bit before use)

@shahzaibkhalid
Copy link

@theKashey In my case, I'm getting the same error and connected components (i.e. dumb components) are not hot-loaded.

react-hot-loader: 4.6.3

@theKashey
Copy link
Collaborator

@shahzaibkhalid - should work if pre-connected part exists as a separate variable. That's also a good idea for better testing.
This root cause of this issue soon will be resolved - #1138

@shahzaibkhalid
Copy link

Yeah. In this case, I realized that the issue was with React-Redux and as I downgraded from v6.0.0 to v5.1.1, it started working.

@wenjoy
Copy link

wenjoy commented Jan 21, 2019

Yeah. In this case, I realized that the issue was with React-Redux and as I downgraded from v6.0.0 to v5.1.1, it started working.

Thanks buddy, you save my day.

@theKashey
Copy link
Collaborator

Would be fixed in react-redux v6.0.1 - reduxjs/react-redux#1168

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

4 participants