christopherafbjur / sanity-plugin-icon-picker

MIT License
29 stars 22 forks source link

Output format for react does not work in V3 #31

Closed HumidBrains closed 1 year ago

HumidBrains commented 1 year ago

Unfortunately this code doesn't change into React output format

{ title: "Icon", name: "icon", type: "iconPicker", options: { outputFormat: 'react', } }

christopherafbjur commented 1 year ago

I just tested this again and I get the expected format which is a CamelCase string. Here's the output from my Sanity V3 Studio:

{
  "_id": "drafts.19f6eb5f-70d3-4d2c-b673-c0cb14fb567a",
  "_type": "icons",
  "icon": {
    "_type": "iconPicker",
    "name": "FiActivity",
    "provider": "fi"
  },
  "_rev": "12d8f44d-2c6b-444d-a837-1bb6a4e666d6",
  "_updatedAt": "2023-03-09T12:52:15.525Z"
}

Based on this example, with outputFormat: 'react' the name you get is FiActivity and without, activity.

Please tell me more about what you did to trigger this potential bug. For instance what is the provider/icon names? @HumidBrains

HumidBrains commented 1 year ago

Hey @christopherafbjur, sorry I'm slow on the ball here. The mystery is solved. I had set all of the icons in Sanity Studio once before I changed the output format to React in the schema. The JSON output in Vision never changed after that, but when returning to the studio I realized all icons were gone. So I set them again and then the data format in Vision got corrected. So all good, maybe only a heads up on this could be worth putting into the documentation. Thanks for a great plugin!

allanleonardjr commented 1 year ago

For what it's worth, I just encountered the exact same problem; my existing values (before I updated the outputFormat to react) did not change after I updated the output format however, new values I add are now being output correctly. Thanks for the tip @HumidBrains 🙌🏾

christopherafbjur commented 1 year ago

Thanks for the feedback! Will add this as a heads up in docs and might expose some utility function that could be used with a migration script to migrate between output formats