
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
react-responsive-mixin
Advanced tools
react-responsive-mixin makes building responsive components easy
This mixin adds method called media()
to the react component.
This is a wrapper around enquire.js
this.media(query, handler)
query
query is a media query definition either in string or object format. This mixin internally uses json2mq to convert media query from object to string format.
handler
handler is a function that needs to be executed when media query matches. handler can also be an object according to enquire.js API
var React = require('react');
var ResponsiveMixin = require('react-responsive-mixin');
var Component = React.createClass({
mixins: [ResponsiveMixin],
getInitialState: function () {
return { url: '/img/large.img' };
},
componentDidMount: function () {
this.media({maxWidth: 600}, function () {
this.setState({url: '/img/small.jpg'});
}.bind(this));
this.media({minWidth:601, maxWidth: 1024}, function () {
this.setState({url: '/img/medium.jpg'});
}.bind(this));
this.media({minWidth: 1025}, function () {
this.setState({url: '/img/large.jpg'});
}.bind(this));
},
render: function () {
return <img src={this.state.url} />;
}
});
FAQs
Mixin to develop responsive react components
The npm package react-responsive-mixin receives a total of 1,368 weekly downloads. As such, react-responsive-mixin popularity was classified as popular.
We found that react-responsive-mixin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.