score:2

function activable(cb) {
  return function wrap(...args) {
    if (process.env.ENABLE_ACTIONS) {
      return cb(...args);
    }
  }
}

function MyComponent() {
   // It's better to pass in anon functions to our activable function so
   // that our function maintains it's scope.  Otherwise you would need
   // to bind the scope. Only if needed I guess, but good to be aware of.
   const onClick = activatable((e) => {
      console.log(e.target);
   });
   return (<button onClick={onClick}>do</button>);
}

Related Query

More Query from same tag