1+ import React , { Component , PropTypes } from 'react' ;
2+ import cloudinary from 'cloudinary-core' ;
3+
4+ export default class Image extends React . Component {
5+ constructor ( props ) {
6+ super ( props ) ;
7+ this . state = { bar : props . initialBar } ;
8+ // this.foo = this.foo.bind(this);
9+ }
10+
11+ componentWillReceiveProps ( nextProps , nextContext ) {
12+ var config = { } ;
13+ cloudinary . Configuration . CONFIG_PARAMS . forEach ( ( param ) => {
14+ if ( nextProps [ param ] ) {
15+ config [ param ] = nextProps [ param ] ;
16+ }
17+ } ) ;
18+
19+ this . setState ( {
20+ url : ""
21+ } )
22+ }
23+
24+ componentWillMount ( ) {
25+ }
26+
27+ componentDidMount ( ) {
28+ }
29+
30+ componentWillUnmount ( ) {
31+ }
32+
33+ componentWillUpdate ( nextProps , nextState , nextContext ) {
34+ }
35+
36+ componentDidUpdate ( prevProps , prevState , prevContext ) {
37+ }
38+
39+ shouldComponentUpdate ( nextProps , nextState , nextContext ) {
40+ return true ;
41+ }
42+
43+ render ( ) {
44+ let cl = cloudinary . Cloudinary . new ( { cloud_name : "demo" } ) ;
45+ var { publicId, transformation, ...other } = this . props ;
46+ var url = cl . url ( publicId , transformation ) ;
47+ return (
48+ < img { ...other } src = { url } />
49+ ) ;
50+ }
51+ }
52+
53+ Image . propTypes = {
54+ publicId : PropTypes . string . isRequired ,
55+ width : PropTypes . oneOfType ( [ PropTypes . number , PropTypes . string ] ) ,
56+ height : PropTypes . number ,
57+ transformation : PropTypes . oneOfType ( [
58+ PropTypes . string ,
59+ PropTypes . object ,
60+ PropTypes . arrayOf ( React . PropTypes . object )
61+ ] ) ,
62+ handleLoad : PropTypes . func ,
63+ breakpoints : PropTypes . oneOfType ( [
64+ PropTypes . func ,
65+ PropTypes . arrayOf ( React . PropTypes . number )
66+ ] )
67+
68+ } ;
69+ Image . defaultProps = { } ;
70+ Image . contextTypes = {
71+ config : React . PropTypes . object
72+ } ;
0 commit comments