ReactDOM.render() "deprecation"

Why was ReactDOM.render(Component, document.getElementById("root")) deprecated? Apparently, using .createRoot, then calling .render on it would work.

Is this to solidify/force React’s framework?

If you are looking for the motivation behind the deprecation of ReactDOM.render in favor of createRoot, take a look at this announcement by one of the React core maintainers.

1 Like

One question. Deprecated, but still valid?

Yes. I think for backward compatibility. Libraries usually replace features with new ones and add the deprecated flag to the old feature without removing it completely to discourage new projects from using the old feature.

Removing a feature completely will break many projects that are already using it. I believe there are several useful React projects and libraries out there relying on READCT.render. It will take a bit of time for them to upgrade to createRoot. Therefore, there is need to keep READCT.render so that old packages that use it will continue to work but new projects shouldn’t use it.

1 Like

Thanks! ----------------

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.