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

🐛 Megamenu - Redundant calls to API that overwrites local data #60

Open
1 of 3 tasks
amankumarrr opened this issue Feb 6, 2024 · 1 comment
Open
1 of 3 tasks

Comments

@amankumarrr
Copy link
Member

amankumarrr commented Feb 6, 2024

Describe the Bug

For our SSW.Website, JSON data generated by TinaCMS is added as a param (i.e menuBarItems) . However, the current implementation calls ssw.com.au/api/get-megamenu regardless of the parameters, leading to overwritten props data.

To Reproduce

Steps to reproduce the behavior:

  1. Install this as a library
  2. Use MegaMenuLayout and pass the prop called menuBarItems

Expected Behavior

It should not call the API if the menuBarItems has data

Tasks

  • Avoid the API call if the menuBarItems is already provided
  • Update REAMDE for NextJS project as it may not run directly due to Server Side Rendering
  • Add ClassName props as an optional prop to add customizable anchor links styling

Ideally, we should export types such as iconMap and other types used for the website's TinaCMS schema, rather than keeping them within the website itself.

Thanks!

@andrewwaltosssw
Copy link
Member

This would be good to sort out. The side effect of refreshing the megamenu data is that it overwrites local and PR slot with the production menu.json making it confusing and poor DX when updating content on MegaMenu.

The suggestion here to conditionally refresh the data only if there is no menuBarItems passed seems reasonable.

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