Do lifecycle hooks work with components?


I have a product content type with variations component like this:

product{ id name slug SKU images { url } brands { name slug } collections { name slug } variations { id sku images{ url } style color size amount price sale } description sold published_at }
I want to sync the fields SKU between a product and its variations, for example, once input the parent SKU (XXXX), the child SKUs are created as XXXX-1, XXXX-2, etc…


Components themselves do not have lifecycles but your product content-type will, within the lifecycle you can use the strapi.query('product').whateverAction() to find/findOne/Update/ect and do the relative sync there as well.


Thanks I just made it.

@lodisy can you share how did you solve your problem?