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

Figure out how to add accurate keys to trackgroups where songs might repeat #141

Open
simonv3 opened this issue May 12, 2022 · 2 comments
Open
Labels
bug Something isn't working needs: api Needs something changed on the resonate API

Comments

@simonv3
Copy link
Collaborator

simonv3 commented May 12, 2022

react-dom.development.js:86 Warning: Encountered two children with the same key, `22826`. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version.
    at tbody
    at table
    at http://localhost:8080/static/js/bundle.js:15018:66
    at http://localhost:8080/static/js/bundle.js:12294:5
    at div
    at History (http://localhost:8080/static/js/bundle.js:3476:83)
    at Outlet (http://localhost:8080/static/js/bundle.js:231284:26)
    at div
    at div
    at Library (http://localhost:8080/static/js/bundle.js:3967:81)
    at Routes (http://localhost:8080/static/js/bundle.js:231376:5)
    at div
    at div
    at http://localhost:8080/static/js/bundle.js:15018:66
    at App (http://localhost:8080/static/js/bundle.js:256:83)
    at AuthProvider (http://localhost:8080/static/js/bundle.js:678:5)
    at GlobalStateProvider (http://localhost:8080/static/js/bundle.js:12853:5)
    at SnackBarContextProvider (http://localhost:8080/static/js/bundle.js:12596:70)
    at ThemeProvider (http://localhost:8080/static/js/bundle.js:15058:64)
    at InsideRouter
    at Router (http://localhost:8080/static/js/bundle.js:231309:15)
    at MemoryRouter (http://localhost:8080/static/js/bundle.js:231218:5)

I haven’t quite figured out what to do with that error. It’s happening because in React when you map to create child elements you need to provide a “key” object so that react can keep track of which element is which for reordering and updating. This key element has to be unique and it can’t just be the index of the array. I’m trackgroups we use the id of the track. But if you’re on a playlist, it could be that the track repeats, cause you’ve played it twice or you added it to the playlist twice.

@simonv3 simonv3 added the bug Something isn't working label May 12, 2022
@whatSocks
Copy link
Collaborator

that's strange - on history the track appears only once even if you play it multiple times.

@simonv3 simonv3 added this to the 0.5.0 milestone May 16, 2022
@simonv3
Copy link
Collaborator Author

simonv3 commented May 16, 2022

Huh, so interestingly enough, if a song appears twice in a playlist that song will have the same index. That seems like an API bug.

GET https://stream.resonate.coop/api/v3/user/trackgroups/43ecfd77-6817-4086-97d2-fe67f0e65f23

image

I put in a temporary fix for this on the front-end, but it needs to be changed to not just be the array's index.

@simonv3 simonv3 added the needs: api Needs something changed on the resonate API label May 16, 2022
@simonv3 simonv3 removed this from the 0.5.0 milestone Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs: api Needs something changed on the resonate API
Projects
None yet
Development

No branches or pull requests

2 participants