How do I conditionally add attributes to React components?

What is a reasonable way to check for this? ECMAScript 6 introduced String.prototype.includes:

const string = "foo";
const substring = "oo";

console.log(string.includes(substring)); // true 

includes doesn’t have Internet Explorer support, though. In ECMAScript 5 or older environments, use String.prototype.indexOf, which returns -1 when a substring cannot be found:

const string = "foo";
const substring = "oo";

console.log(string.indexOf(substring) !== -1); // true