In my component, I have computed properties that rely on properties outside of the component. I’m aware that instead of using computed properties, I can place the computations inside the didRecieveAttrs lifecyle hook.
I know that we should try to avoid observables as much as possible but does the same thing apply for computed properties? Should we avoid computed properties and instead do it in one of the hooks of a components?
I’m not sure if people agree on a best practice for this yet, but I think it will be really interesting to try both ways and see which feels better. React gets by with exclusively using hooks and Ember has used CPs for a long time.
One case where I don’t think the lifecycle hooks will work is if you have a CP that relies on the properties of a service. However it might be better to register callbacks or use events with a service. Can’t wait to see how these lifecycle hooks change the way we write components!
Bringing this back up again. After a few months, I’m still leaning towards using computed properties rather than the new lifecycle hooks. Though I’m still not sure what direction Ember is going. I don’t want to overuse computed properties when only to find out that we’re actually heading towards lifecycle hooks on Glimmer components.
I think the other hooks have some good purposes but the didReceiveAttrs() and computed properties are overlapping. I guess that’s where I’m confused on what to lean on more.
Can someone shed some light?