Let's say I have a component like this:
<TouchableOpacity activeOpacity={1} />
And in some cases I would like to add a property pointerEvents or something similar like so:
<TouchableOpacity pointerEvents={'box-none'} activeOpacity={1} />
Recently I have been accomplishing this by setting a variable and passing it to the component based on some internal state like so:
render() {
const pointerType = this.state.isVisible ? 'box-none' : 'box-only';
return (
<TouchableOpacity pointerEvents={pointerType} activeOpacity={1} />
)
}
However, in some cases this is not ideal and I was wondering if there was a way to dynamically include the property like so:
render() {
const pointerJSX = this.state.isVisible ? {pointerEvent:'box-none'} : null;
return (
<TouchableOpacity {pointerJSX} activeOpacity={1} />
)
}