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

Current marker data doesn't change when panel props change #44

Open
phocks opened this issue Aug 10, 2022 · 0 comments · May be fixed by #45
Open

Current marker data doesn't change when panel props change #44

phocks opened this issue Aug 10, 2022 · 0 comments · May be fixed by #45

Comments

@phocks
Copy link
Member

phocks commented Aug 10, 2022

In previous versions of scrollyteller we could apparently change panels props and then onMarker would fire the new data. In version 4 due to memoising or callbacking or something, only the original panel data is sent to the onMarker function.

Our Income Inequality piece uses this to send the user to a different part of the map depending on which LGA they are in.

Anyway I tried a number of different ways to make the panelReferences update when panels prop data changes, but without much luck.

One way to solve this (but this is kinda hacky) is to do something like this:

.map(({ element, measurements }, i, arr) => {
          const actualPanelData = panels[i].data;
          ...
          return {
            element,
            data: actualPanelData,
            ...
          };
        });

... which grabs the panel data from the actual panels prop.

This seems to update fine and fires off the data onMarker. There's gotta be a better way though.

@phocks phocks linked a pull request Aug 10, 2022 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant