alexandrtovmach/react-figma-plugin-ds

Missing "checked" state in Checkbox Component

girafic opened this issue · 3 comments

Missing "checked" state in Checkbox Component

Thanks for report 👍
Expected result is to use defaultValue prop for that. There are two things:

  1. controlled vs. uncontrolled component
  2. value vs. checked

This framework using "uncontrolled component" approach, which means that you can set only initial value by defaultSomething.
Semantic question about value vs. checked is debatable point. From my perspective, better to keep consistent props for all components, that's why we have defaultValue instead of defaultChecked.

Thx for clarification, will work then with defaultValue 😊

Hey @alexandrtovmach, I may be missing the right approach, but I am running into an issue due to this.

I am retrieving data in the index.tsx from figma via the api. I need to change a toggle depending on the result.
However I think that due to the missing checked property I am not able to do this. The issue is, that the onmessage event is not run before the ui is rendered, so when the ui is initialized (and defaultChecked is used) I don't have access to the data yet.

Could you maybe add the checked attribute as well, so that I can solve this problem?