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

DataTable: Filter Menu not displayed when inside <React.StrictMode> in React 18 #2777

Closed
inad9300 opened this issue Apr 20, 2022 · 6 comments · Fixed by #2986
Closed

DataTable: Filter Menu not displayed when inside <React.StrictMode> in React 18 #2777

inad9300 opened this issue Apr 20, 2022 · 6 comments · Fixed by #2986
Assignees
Labels
React 18 Issue or pull request is *only* related to React 18 Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@inad9300
Copy link
Contributor

inad9300 commented Apr 20, 2022

In case it helps you with the adoption of React 18,

I'm submitting a...

[x] bug report
[ ] feature request
[ ] support request

Codesandbox Case
https://codesandbox.io/s/primereact-test-forked-vkirpl?file=/src/index.js

Current behavior
When opening the filter menu, only the "Clear" and "Apply" buttons appear.

Expected behavior
The actual filters should be shown too.

  • React version: 18.0.0
  • PrimeReact version: 8.0.0-rc.2
  • Browser: at least Chromium

Does NOT Work:

ReactDOM.createRoot(document.getElementById("root3")).render(
  // remove StricMode and the app works fine
  <React.StrictMode>
    <App />
  </React.StrictMode>
);

Works:

ReactDOM.createRoot(document.getElementById("root3")).render(
    <App />
);
@inad9300 inad9300 changed the title Table column menu filter not displayed when inside <React.StrictMode> Table column menu filter not displayed when inside <React.StrictMode> in React 18 Apr 20, 2022
@melloware
Copy link
Member

melloware commented Apr 20, 2022

I updated your code sandbox reproducer to better show the issue: https://codesandbox.io/s/primereact-test-forked-vkirpl?file=/src/index.js

Does NOT Work:

ReactDOM.createRoot(document.getElementById("root3")).render(
  // remove StricMode and the app works fine
  <React.StrictMode>
    <App />
  </React.StrictMode>
);

Works:

ReactDOM.createRoot(document.getElementById("root3")).render(
    <App />
);

@melloware melloware changed the title Table column menu filter not displayed when inside <React.StrictMode> in React 18 DataTable: Filter Menu not displayed when inside <React.StrictMode> in React 18 Apr 20, 2022
@melloware melloware added the Type: Bug Issue contains a defect related to a specific component. label Apr 20, 2022
@melloware
Copy link
Member

melloware commented Apr 21, 2022

Found this: https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html#updates-to-strict-mode

Look like Strict Mode is way different in React 18 it must be causing this issue <StrictMode>

@leischj
Copy link

leischj commented May 25, 2022

Just wanted to add that using filterDisplay={'row'} also is failing in with React 18 (in StrictMode). It fails with this error:

TypeError
Cannot set properties of undefined (setting 'value')
onInputChange ......

I forked the sandbox here: https://codesandbox.io/s/primereact-test-forked-5nx688?file=/src/index.js

@JeffreyStevens
Copy link

I also have this error in my project, thank you!

desmondsow added a commit to desmondsow/primereact that referenced this issue Jun 12, 2022
…gering filter

###Defect Fixes
Fix primefaces#2777: Check if `globalFilter` is not null because triggering filter

Check if `globalFilter` is not null because triggering filter in React 18 StrictMode when double-invoking effects (mount -> unmount -> mount)
@desmondsow
Copy link
Contributor

Hi @melloware, submitted a PR for this issue. Fix both this issue and #2947

@melloware melloware added this to the 8.2.0 milestone Jun 12, 2022
@melloware
Copy link
Member

Excellent thank you for the PR!

melloware pushed a commit that referenced this issue Jun 12, 2022
…ter (#2986)

###Defect Fixes
Fix #2777: Check if `globalFilter` is not null because triggering filter

Check if `globalFilter` is not null because triggering filter in React 18 StrictMode when double-invoking effects (mount -> unmount -> mount)
@melloware melloware added the React 18 Issue or pull request is *only* related to React 18 label Jul 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
React 18 Issue or pull request is *only* related to React 18 Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants