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

Different appearances of components when using react-hot-loader #2630

Closed
wdiu opened this issue Jun 25, 2018 · 8 comments · Fixed by #5929
Closed

Different appearances of components when using react-hot-loader #2630

wdiu opened this issue Jun 25, 2018 · 8 comments · Fixed by #5929
Labels
package: react carbon-components-react severity: 2 User cannot complete task, and/or no workaround status: waiting for author's response 💬 type: bug 🐛

Comments

@wdiu
Copy link

wdiu commented Jun 25, 2018

As stated in
https://github.com/carbon-design-system/carbon-components-react/blob/master/README.md:
"1.These components require the use of Webpack in your project"

Typically, development webpack configurations use react-hot-loader while production webpack configurations don't.

But carbon-components-react does not work with react-hot-loader, resulting in totally different appearances / behavior in development and production.

For example, in TableBody.js:
if (child.type === TableRow)

This will work fine in production where there is no hotloading, but not in development when there is hotloading.

The reason: gaearon/react-hot-loader#304

The fix is explained in the section on Checking Element types at https://github.com/gaearon/react-hot-loader/blob/master/README.md

This issue is similar to https://github.com/carbon-design-system/carbon-components-react/issues/857 but the difference is that it is not just the childrenOf and childrenOfType that are failing; components appear totally different.

@elbrus
Copy link

elbrus commented Jul 24, 2018

Any update on this?

I have similar issue with ComposedModal component. There is a check on line 67, which fails when RHL is used.
It's annoying as now I need to add two events to check for modal closing: closeModal and buttonOnClick. One works without RHL, another with RHL.

@stale
Copy link

stale bot commented May 2, 2019

We've marked this issue as stale because there hasn't been any activity for a couple of weeks. If there's no further activity on this issue in the next three days then we'll close it. Thanks for your contributions.

@wdiu
Copy link
Author

wdiu commented May 2, 2019

@joshblack, Is this really "won't fix"?

Hot loading is very important for development use.

@dakahn
Copy link
Contributor

dakahn commented May 3, 2019

@wdiu That 'Wont fix' label was applied by our stale bot. Sorry!

That said -- would it be possible to provide us with some sort of testable example of what you're talking about here so we can triage and look into a solution?

@wdiu
Copy link
Author

wdiu commented May 3, 2019

The easiest way to reproduce this is to enable hot loading in your development webpack.js.

In the entry array, add

        'react-hot-loader/patch',
        'webpack/hot/only-dev-server'

In the plugins array, add
new webpack.HotModuleReplacementPlugin(),
In the devServer object, add
hot: true,

A more complete webpack.js might look like

module.exports = {
    entry: [
        'babel-polyfill',
        'react-hot-loader/patch',
        'webpack/hot/only-dev-server',
        'webpack-dev-server/client?http://0.0.0.0:8080',
        './startingFile.jsx'
    ],

    ... //whatever you had in your webpack before

    devServer: {
        hot: true,
        ... //whatever you had here before
    },

    plugins: [
        new webpack.HotModuleReplacementPlugin(),
        new webpack.NamedModulesPlugin(),
    ],

    watch: true
}

@dakahn
Copy link
Contributor

dakahn commented May 3, 2019

@joshblack @emyarod any insight into this?

I'll try and recreate the error if I can

@asudoh
Copy link
Contributor

asudoh commented May 3, 2019

Some sources say that if (child.type === <TableRow>.type) (meaning, getting the type of an instantiated version instead of direct React component ref) solves this problem, but we don't have a test case for this. That said, as @dakahn brought up, a test case is an important piece.

@carbon-bot carbon-bot transferred this issue from carbon-design-system/carbon-components-react May 9, 2019
@carbon-bot carbon-bot added package: react carbon-components-react severity: 2 User cannot complete task, and/or no workaround status: waiting for author's response 💬 type: bug 🐛 labels May 9, 2019
@carbon-bot
Copy link
Contributor

Hi there! 👋 If you're wondering why this issue was moved, we're currently updating our repo structure so that every package is found in the same project.

This should not have any impact for you, but we wanted to give you a heads up in case you were wondering what is going on. If you have any questions, feel free to reach out to us on Slack or contact us at: carbon@us.ibm.com. Thanks!

@project-bot project-bot bot added this to Issue: needs triage 💊 in Carbon support May 9, 2019
@dakahn dakahn moved this from Issue: needs triage 💊 to Issue: backlog in Carbon support May 14, 2019
asudoh added a commit to asudoh/carbon-components that referenced this issue Apr 24, 2020
This change fixes the issue that comes with unmatched component class
ref vs. its RHL-proxied version. The issue was observed with running
`<ComposedModal>` in Carbon website's component live demo pane, opening
the modal and hitting the close button.

Applied a similar fix to `<DatePicker>`.

Fixes carbon-design-system#2630.
asudoh added a commit to asudoh/carbon-components that referenced this issue Apr 24, 2020
This change fixes the issue that comes with unmatched component class
ref vs. its RHL-proxied version. The issue was observed with running
`<ComposedModal>` in Carbon website's component live demo pane, opening
the modal and hitting the close button.

Applied a similar fix to `<DatePicker>`.

Fixes carbon-design-system#2630.
Carbon support automation moved this from Issue: backlog to Closed Apr 29, 2020
asudoh added a commit that referenced this issue Apr 29, 2020
This change fixes the issue that comes with unmatched component class
ref vs. its RHL-proxied version. The issue was observed with running
`<ComposedModal>` in Carbon website's component live demo pane, opening
the modal and hitting the close button.

Applied a similar fix to `<DatePicker>`.

Fixes #2630.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: react carbon-components-react severity: 2 User cannot complete task, and/or no workaround status: waiting for author's response 💬 type: bug 🐛
Projects
No open projects
Carbon support
  
Closed
Development

Successfully merging a pull request may close this issue.

6 participants