For example lets say I want to remove images when display size falls below 600px width. What would be the cleanest, fastest and most maintainable method to do that?
<div class="card">
<div class="image">
<img src="http://placehold.it/256x256">
</div>
<div class="content">
<a class="header">Kristy</a>
<div class="meta">
<span class="date">Joined in 2013</span>
</div>
<div class="description">
Kristy is an art director living in New York.
</div>
</div>
<div class="extra content">
<a>
<i class="user icon"></i>
22 Friends
</a>
</div>
</div>
EDIT: Definitely not using jQuery (it works, but read below):
jQuery Free
jQuery is a DOM manipulation library. It reads from and writes to the DOM. React uses a virtual DOM (a JavaScript representation of the real DOM). React only writes patch updates to the DOM, but never reads from it.
It is not feasible to keep real DOM manipulations in sync with React's virtual DOM. Because of this, all jQuery functionality has been re-implemented in React.
<script>
$(window).resize(function () {
if (window.innerWidth < 600) { //Some arbitrary mobile width
$(".image img").attr("src", "");
} else {
$(".image img").attr("src", "http://placehold.it/256x256");
}
});
</script>
<div class="ui container desktop only grid">
Contents
</div>
render() {
let content = this.state.width < 600 ? <MobileComponent/> : <DesktopComponent />;
return(<div>
<div>{content}</div>
<childComponent myWidth= {this.state.width}></childComponent >
<childComponent2 myWidth= {this.state.width}></childComponent2 >
</div>
)