storyblok / field-plugin

Create and deploy Storyblok Field Plugin
https://www.storyblok.com/docs/plugins/field-plugins/introduction
MIT License
25 stars 3 forks source link

feat(lib): updater functions #206

Closed johannes-lindgren closed 1 year ago

johannes-lindgren commented 1 year ago

Issue: EXT-1558

What?

setContent and setModalOpen now accept updater functions as arguments.

Why?

In React and other frameworks with batched updates, unless you update a state with an updater function, multiple calls to setState will result in only a single update, because the latter updates overwrite the previous ones.

The same thing can happen in a field plugin with setContent and setModalOpen.

How to test? (optional)

Run the demo and try out the new button "IncrementTwice".

image

(The background is being fixed in #205)

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
plugin-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 19, 2023 8:26am