Jul 4, 2021
Ah, yes.
This is a pretty standard situation for components that rely on input that will come later. You always need to either:
- ensure that your component will never get an undefined property,
- provide reasonable defaults for your properties, or
- consider how your component should behave when it starts with undefined information.
Because React is data-driven, you need to consider those situations where there’s no data. This has less to do with how the property is populated, and more with the fact that, sometimes, it just might not be.
¯\_(ツ)_/¯