Why is it not possible anymore to access the data of components in the beforeUpdate-Hook?
Why is the component already safed to the database when reaching the beforeUpdate-Hook?
What was the architectural thinking behind that?
How are we supposed to access the data of components in the beforeUpdate-Hook?
If we edit an entity in strapi the strapi.service.update-Method is not even called.
Is there an elegant way to override the update of the entityService?
Strapi was quite powerful in v3 - but in comparison - in v4 many options was taken away from the developers. I do not want to fight restrictions that strapi seems create on purpose with v4.
5 Likes
I am also wondering:
How are we supposed to access the data of components in the beforeUpdate-Hook?
I just started working with strapi a couple of months ago and only used V4. It really strikes me that this feature isn’t included.
I think components, especially in combination with dynamic zones are fantastic to model more complex data structures and still getting an easy to use interface in the Content Manager.
I am currently using components to model material variations for a material catalog and I want to process the data of the components in beforeCreate and beforeUpdate and store the resulting json in a json data field.
This seems to me like quite a common use case.
So is there any plan to add this back in? Because any workaround is performance wise not great…
5 Likes
I have the same question. Who came up with such a “great” idea?
I need to check the data before saving it, and if it doesn’t match the previous state, then perform a series of actions. It turned out that I can’t get access to the previous state of the object in any way, since at the moment beforeUpdate the component is already updated…
Hey @snoyter,
you are absolutely right: This is bullshit done by Strapi.
Naming something beforeUpdate even if the update already IS done (partially). 
However you can work around that…
We needed it in only some rare cases - and only via actions that are performed via REST-API so we decided to:
Create our own update-Service to use inside these controllers. Inside this update-Service we perform a find on the “to be updated”-entity.
Then we perform the update.
If you however need it to work via Strapi Admin you might need to patch-package some Strapi sources for that. 