MenuBar: On change of model, processed items are not being updated as they are cached with useCallback #6997
Labels
Type: Bug
Issue contains a defect related to a specific component.
Milestone
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: