You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On change of menu bar model, it's calling createProcessedItems which is using useCallback. So according to react, useCallback hook returned cached if the dependency array is not changed. In line https://github.com/primefaces/primereact/blob/master/components/lib/menubar/Menubar.js#L514, no dependencies are provided. because of this, if the model is changed in level 2, the output of createProcessedItems is not changing.
So the solution is to provide the dependency items to createProcessedItems useCallback hook as props.model so that when the model changes the output will change without cache.
Reproducer
No response
System Information
Primereact latest
Steps to reproduce the behavior
Happens on change of model in level 2.
Expected behavior
It should give new processed items every time model change.
The text was updated successfully, but these errors were encountered:
melloware
changed the title
menubar: On change of model, processed items are not being updated as they are cached with useCallback
MenuBar: On change of model, processed items are not being updated as they are cached with useCallback
Aug 6, 2024
melloware
added
Type: Bug
Issue contains a defect related to a specific component.
and removed
Status: Needs Triage
Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
labels
Aug 6, 2024
Describe the bug
On change of menu bar model, it's calling
createProcessedItems
which is using useCallback. So according to react, useCallback hook returned cached if the dependency array is not changed. In line https://github.com/primefaces/primereact/blob/master/components/lib/menubar/Menubar.js#L514, no dependencies are provided. because of this, if the model is changed in level 2, the output of createProcessedItems is not changing.So the solution is to provide the dependency items to
createProcessedItems
useCallback hook asprops.model
so that when the model changes the output will change without cache.Reproducer
No response
System Information
Primereact latest
Steps to reproduce the behavior
Happens on change of model in level 2.
Expected behavior
It should give new processed items every time model change.
The text was updated successfully, but these errors were encountered: