JSFiddle - React, Tailwind, and code Playground

HTML

<div id="range"></div>
<div id="items"></div>
<div>Adding the call to domain remedies the issue and it behaves as expected.</div>

CSS

div {margin-top: 12px}

JavaScript

var colors = d3.scale.category10();
colors.domain(d3.range(0, 10)); // The fix.
console.log(colors.range());
// Produce a pretty output in addition to console log.
var range = d3.select("#range");
colors.range().forEach(function(item) {
    range.append("span").style("color", item).text(item);
});

console.log(colors(1), colors(0));
// Pretty output.
var items = d3.select("#items");
[colors(1), colors(0)].forEach(function(item) {
   items.append("span").style("color", item).text(item);   
});