React 怎么让滚动条自动在右边

#1
let doc = document.getElementById("root");
console.log(doc.scrollWidth);
doc.scrollLeft = doc.scrollWidth;

这句话 用了之后没起作用。