3 ms·
React encourages writing core logic in a DOM agnostic way. What you're saying is not only true of different frameworks; once code touches the DOM it's poison fo
by HeyImAlex 11y ago
React encourages writing core logic in a DOM agnostic way. What you're saying is not only true of different frameworks; once code touches the DOM it's poison for reusability, and you can see it even inside of the react ecosystem. The key is to abstract out a pure logical model, and then build your actual DOM-touching instances ontop of that.
- JDDunn9 11y ago> once code touches the DOM it's poison for reusability source? In reality, it's quite the opposite. You can't easily convert a React component to another framework. The key to writing reusable code is to remove dependencies.
- HeyImAlex 11y agoReact is ultimately a framework for managing DOM mutations, so it would make sense that a pure logical model that doesn't touch the DOM also doesn't have a dependency on React.
- jhgg 11y agoNot true. React is a framework for managing state trees and mutations. As of 0.14, react has nothing to do with the dom at all. All that logic has been moved to react-dom.