4 ms·
How do you keep the saved data props/values (title, description) in sync with the component props in the code? Let's say I change `description` to `subtitle` in
by nathancahill 3y ago
How do you keep the saved data props/values (title, description) in sync with the component props in the code? Let's say I change `description` to `subtitle` in the code, what happens to that information?
- chrisvxd 3y agoWe let the user decide how they want to store the data via the `onSave` and `onChange` callback props you provide to the `<Puck>` component. So you would likely save to your own database in the callback. The data shape is detailed here: https://github.com/measuredco/puck#data https://github.com/measuredco/puck#data
- nathancahill 3y agoI'm trying to understand if the layout immediately becomes brittle once the data is saved (unless someone goes in to the saved data and patches it by hand when the layout is updated).
- chrisvxd 3y agoSorry I got the wrong end of the stick. Please see my other reply to your comment.
- chrisvxd 3y agoI just re-read your comment and realised I didn't answer it first time around. The best way to handle this is in the render function you pass to Puck, which can continue to support the old prop (`description`) and map into the new prop (`subtitle`), even if it's not provided by the author. We don't have a system for migrating props in the actual data yet, but it's something we could look into.
- chrisvxd 3y agoTracking this here, with proposal: https://github.com/measuredco/puck/issues/41 https://github.com/measuredco/puck/issues/41