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 · 1 comment
Open
1 task done
Labels
pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised

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] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised 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
@fgiuliani
Copy link
Collaborator

Hi @marekrozmus, sorry for the late response. During the last months of this year and last year, several changes were introduced to storyblok-js-client, the library this React SDK depends on.

Let me check with the team, but from my understanding it's not an issue but a change added to support a different scenario. A use case that comes to my mind: When using the Storyblok Management API to create/edit a story, the blocks of that story might not have a _uid assigned.

cc @alvarosabu @alexjoverm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised
Projects
None yet
Development

No branches or pull requests

2 participants