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

Usage of the _uid as a React key? - the field has type string | undefined #1045

Open
1 task done
marekrozmus opened this issue Apr 14, 2024 · 0 comments
Open
1 task done
Labels
pending-author [Issue] Add Storyblok employee pending-triage [Issue] Add labels to describe it or prioritise it

Comments

@marekrozmus
Copy link

marekrozmus commented Apr 14, 2024

Describe the issue you're facing

I am using pretty old version of the lib (1.3.3) and tried to upgrade that in the project but one of the problems is that the type of the _uid was changed at some point from _uid: string; to _uid?: string;.
I am using it in the project everywhere when enumerating children.
Is this a typing issue or the _uid can be actually in some cases undefined and I should update the project to stop using that as a React key?

Same with component: TComp; is now: component?: T; - so I cannot be sure that the component will be always set?

I know this is the code from storyblok-js-client but it has direct impact on this lib and I am wondering how to solve that.

Reproduction

https://github.com/storyblok/storyblok-js-client/blob/644fd93eae990a9f0e36c59c68aa9fab9d81469a/src/interfaces.ts#L76

Steps to reproduce

No response

System Info

"node_modules/@storyblok/react": {
      "version": "3.0.9",
      "resolved": "https://registry.npmjs.org/@storyblok/react/-/react-3.0.9.tgz",
      "integrity": "sha512-N362hE+sBH3QebCrJtqgzGI2l+Dre8hfNJmAJvEtx1bEtfvu6hcA5ch5eQjjILxgDMwtseA0BnCXP7zoqJ2KCg==",
      "dependencies": {
        "@storyblok/js": "^3.0.7"
      },
      "peerDependencies": {
        "react": "^17.0.0 || ^18.0.0",
        "react-dom": "^17.0.0 || ^18.0.0"
      }
    },

Used Package Manager

npm

Error logs (Optional)

No response

Validations

@marekrozmus marekrozmus added pending-author [Issue] Add Storyblok employee pending-triage [Issue] Add labels to describe it or prioritise it labels Apr 14, 2024
@marekrozmus marekrozmus changed the title Cannot use the _uid as a React key in Typescript as the field has type string | undefined Usage of the _uid as a React key? - the field has type string | undefined Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-author [Issue] Add Storyblok employee pending-triage [Issue] Add labels to describe it or prioritise it
Projects
None yet
Development

No branches or pull requests

1 participant