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

MenuBar: On change of model, processed items are not being updated as they are cached with useCallback #6997

Closed
srikanth-nallamothu opened this issue Aug 6, 2024 · 1 comment · Fixed by #6999
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@srikanth-nallamothu
Copy link

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 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.

@srikanth-nallamothu srikanth-nallamothu added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Aug 6, 2024
@melloware 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 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
@melloware melloware added this to the 10.8.3 milestone Aug 6, 2024
@melloware melloware self-assigned this Aug 6, 2024
melloware added a commit to melloware/primereact that referenced this issue Aug 6, 2024
@melloware
Copy link
Member

PR submitted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants