The default field of the component used by react cannot pass a value.

Development environment: react antd

I wrote a new component myself < ModelItem/ > put it in modelSetting

and then I wrote it like this

clipboard.png

keygetModelDataAgain

keykey22key22

clipboard.png

Why, even if key is the default field, can"t I overwrite it? Obviously passed in key, but can not get, display undefined.

Mar.10,2021
The key property in

react is a special property that appears not for developers (for example, you can't get the component's key props), after you set key for a component, but for react's own use. Please refer to https://codeshelper.com/a/11.


this is true in terms of the design of the React framework, and you cannot override this attribute. key is set for react to compare DOM nodes, not to pass parameters to users using the react framework.

Github react issue there is a discussion of similar issues, which you can take a look at if you are interested.

https://github.com/facebook/r.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bde2cc-54037.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bde2cc-54037.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?