storyblok-react
storyblok-react copied to clipboard
Usage of the _uid as a React key? - the field has type string | undefined
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
- [X] Follow our Code of Conduct
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