How to save block attributes when the output doesn’t change

Actually an assumption I made in the question was wrong; The update button doesn’t only change when the output of the save function changes. It also changes when the attributes are changed.

However I found a small bug, which you can’t really see it in the provided code. In my BlockSettings component I was using useState to update the settings inside to the component. I would also emit the settings immidiately after assigning them.

useState is however an async function. So in fact I was emitting the old value. Since I emitted the old value the attributes were identical to the values before. Therefore not triggering an update.

The fix was quite easy. Using useEffect to react on the changed value did the trick for me.

So if the update button isn’t triggering, doublecheck if you actually changed the attributes.

Leave a Comment