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

react-hot-loader & formatter change #1080

Closed
aogaili opened this issue Aug 31, 2019 · 3 comments
Closed

react-hot-loader & formatter change #1080

aogaili opened this issue Aug 31, 2019 · 3 comments
Assignees

Comments

@aogaili
Copy link

aogaili commented Aug 31, 2019

I'm noticing that react-hot-loader is not refreshing the component when I change the column formatter function (it works when changing text or align attributes).

I plan to open an issue in the react-hot-loader repo, but I wanted to see if anyone else is using it in the context of react-hot-loader and noticing similar issues. The current workaround is to use key= Math.random() to force react to re-render the component.

I'm using react-hot-loader 4.12.12.

@AllenFang
Copy link
Member

@aliogaili I didn't notice this issue. but how did you change the column formatter function? Would you please describe it a bit more? Thanks!

@aogaili
Copy link
Author

aogaili commented Sep 7, 2019

I've react-hot-loader configured to accept module changes on the parent container and down the component tree I've a table.

In the table I pass a custom formatter, nothing special:

{ dataField: 'addedOn', text: 'Added On', align: 'center', headerAlign: 'center', formatter: (cell, row) => { return <div>This Doesn't hot reload</div>; }

If I change the formatter function, for example change the text, the effect won't hot reload until I force refresh. Again, this is issue is only observed with react-hot-loader (storybook it works, but they have their own hot-reloader implementation).

My current workaround is to generate a random key:

key={DataTable.hotKey()}

// A hack to make it work with react-hot-loader
DataTable.hotKey = () => {
  if (module.hot) {
    return Math.random();
  }
  return undefined;
};

I'm not sure if this is only local to my webpack/react-hot-loader setup or a general issue, I think we need a smaller reproduction. I really hope the new react fast refresh will iron those glitches out.

@AllenFang
Copy link
Member

Thanks your quick reply @aliogaili
it might be an issue in react-hot-loader, Let's see if fast refresh could solve this issue.

@aogaili aogaili closed this as not planned Won't fix, can't repro, duplicate, stale Sep 11, 2023
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

2 participants