I need to implement a logic which controls weather different components are enabled or disabled depending on a date and a configuration value. The date is selected by the user and the the configuration value is provided by an Webservice. Both values a stored in a redux store.
I'm wondering whats the best way to achive this without having code duplication and without a tight coupling.
I have thought about this following solutions:
- Creating an higher order component which is connected to the store and sets the disabled property of it's child
- Using the react context API to provide an instance of an service class which contains the verification logic
- Creating a simple function which contains the logic and is imported into the component
At the moment I'm preferring the first way. But maybe there is a proven practice which I'm not aware of?
I'm looking forward to any suggestions on this topic.