Block API: Deprecate id prop in favor of clientId#7669
Conversation
jorgefilipecosta
left a comment
There was a problem hiding this comment.
thus not requiring a warning to be shown except in the case of blocks making use of this prop
Hi @aduth, the changes look good, but In my tests, If I create a new post and I press the "Write your story" placeholder I see the warning right away even though we are not using the id attribute. May some debugging tool is causing the message to appear.
I used this test block https://gist.github.com/jorgefilipecosta/aa2cc6c59e6e53279e5b04607510dc58 that uses id and things worked as expected.
|
Hmm, good catch @jorgefilipecosta . I'm not sure why I wasn't seeing or didn't notice that previously. I suppose it could make sense if React is iterating over the props that the getter is inevitably going to be called. To move forward, I'm wondering:
|
|
Rebased to resolve conflicts. I decided to just add a global warning to |
jorgefilipecosta
left a comment
There was a problem hiding this comment.
Looks good to be 👍 A global deprecation message seems to be the best option in this case.
I did some grepping and I did not find any usages of id in core-blocks.
Related: #6741 (comment)
This pull request seeks to propose deprecating the block
idprop, which was never consistent, with a new standardization toward referencing a block'suidas itsclientId. This is also intended as part of a capitalization normalization effort, where equivalent selectors and internal props are planned to be updated as well. The idea with the changes here are to deprecate early for the public-facing API, ahead of the upcoming 3.2 release.Testing instructions:
Verify there are no regressions in the behavior of blocks.
To my knowledge, no core blocks use the
idprop. You can add this to an existing block to test that the deprecated warning is shown, but the behavior ofidis otherwise unaffected.Related: Confirmation that destructuring of objects triggers getters (and therein the
deprecated), thus not requiring a warning to be shown except in the case of blocks making use of this prop:https://codepen.io/aduth/pen/VdRmav?editors=1111