react-tracking
react-tracking copied to clipboard
Multiple options.process behavior
Currently we encourage to use only one process
on top level component, by making checks in constructor method of every tracking HoC
constructor(props, context) {
super(props, context);
if (context.tracking && context.tracking.process && process) {
console.error('[nyt-react-tracking] options.process should be used once on top level component');
}
}
Could these checks be performance consuming?
If there are several usages of options.process
down a component tree desired behavior should be:
- display error message (current behavior)
- child's process should override parent's
- merge return values of each
- do nothing, because everyone should read documentation ;)
- ...?
One option is to guard these checks against a NODE_ENV check, which should be optimized and dead-code eliminated by a properly configured Webpack build:
constructor(props, context) {
super(props, context);
if (process.env.NODE_ENV !== 'production' && context.tracking && context.tracking.process && process) {
console.error('[nyt-react-tracking] options.process should be used once on top level component');
}
}