Checklist-Tools-Website
Checklist-Tools-Website copied to clipboard
Fix bug where >2 links causes duplicates on page re-rendering
- Prior to this fix, any task object that had greater-than 2 links would duplicate n-1 of those links every time the page rendered.
I made an assumption that it had something to do with Preact duplicating based on passing the entire
link
object tokey=
and it seems to work simply by removing thekey=
attribute altogether. - Also removed the unused
i
parameter
Full disclosure: I have really no actual idea why it was duplicating links in the first place and merely got lucky with this patch. I'm not a JS developer and don't understand the code very well to really understand what was happening at the Preact level for it to duplicate link items.
I do know that the data object in localStorage was fine, so it seems to be a rendering issue only.
You should be able to replicate with this JSON:
{
"group_categories": [
{
"title_group": "Heading",
"categories": [
{
"tasks": [
{
"explications": "This area will start to duplicate links after a re-render",
"links": [
{
"text": "Google",
"type": "tools",
"path": "https://google.com"
},
{
"text": "Github",
"type": "link",
"path": "https://github.com"
},
{
"text": "Gitlab",
"type": "link",
"path": "https://gitlab.com"
}
],
"title": "Duplicate links after >2"
}
],
"title": "Task title"
}
]
}
],
"name": "Test checklist for duplicate links"
}