Skip to content

[BUG] QueryRenderedFeatures.svelte crashes if feature.id is undefined in each block #140

@arnaud-leakmited

Description

@arnaud-leakmited

Description

QueryRenderedFeatures.svelte crashes if feature.id is undefined

Use case

Using the component with an MVT server that does not provide ids for a feature will throw an error in the {#each} block

Uncaught Svelte error: each_key_duplicate
Keyed each block has duplicate key `undefined` at indexes 0 and 1
https://svelte.dev/e/each_key_duplicate

  in <unknown>
  in QueryRenderedFeatures.svelte
// line 58
{#if children}{#each features as feature (feature.id)}{@render children(feature)}{/each}{/if}

Feature may have an undefined id, so the component should handle the case.

// MapLibre

export declare class GeoJSONFeature {
//
	id: number | string | undefined;
//
}

I have a fix and will push a PR shortly

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions