I want to use Picturefill + React + React Router (Also using Webpack).
Context: There is no isomorphic architecture yet so the data is fetched after initial page load (Route change).
…Because of this the render method is being called twice.
render: function () {
return (
<picture>
<!-- You get the idea -->
<source srcSet={this.props.large} media="(min-width: 1024px)" />
<source srcSet={this.props.medium} media="(min-width: 640px)" />
<img srcSet={this.props.small} />
</picture>
);
}
<head>
<!-- Recommended usage -->
<script src="https://cdn.rawgit.com/scottjehl/picturefill/2.3.1/dist/picturefill.js"></script>
</head>
// Use picturefill JavaScript API
componentDidUpdate() {
picturefill();
}
More info/Alternatives?
I would recommend, that you use picturefill 3.0 RC1 in combination with the mutation plugin. This way you don't need to call picturefill();
, everything is done automatically.
This will work in any browser.