Skip to content

Commit 5d506b5

Browse files
author
Nir Maoz
authored
Fix contextType to be class property of CloudinaryComponent (#145)
1 parent c7af6ea commit 5d506b5

File tree

13 files changed

+38
-36
lines changed

13 files changed

+38
-36
lines changed

babel.config.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
"use strict";
22

3-
module.exports = function (api){
3+
module.exports = function (api) {
44
api.cache.never();
55
return {
6-
plugins: ["@babel/proposal-export-default-from"],
7-
"presets":
8-
["@babel/preset-env", "@babel/preset-react"],
9-
}};
6+
plugins: [
7+
"@babel/proposal-export-default-from",
8+
"@babel/plugin-proposal-class-properties"
9+
],
10+
"presets":
11+
["@babel/preset-env", "@babel/preset-react"],
12+
}
13+
};

docs/iframe.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@
5757
console.warn('unable to connect to parent frame for connecting dev tools');
5858
}</script></head><body><div class="sb-nopreview sb-wrapper"><div class="sb-nopreview_main"><h1 class="sb-nopreview_heading sb-heading">No Preview</h1><p>Sorry, but you either have no stories or none are selected somehow.</p><ul><li>Please check the storybook config.</li><li>Try reloading the page.</li></ul></div></div><div class="sb-errordisplay sb-wrapper"><div id="error-message" class="sb-heading"></div><pre class="sb-errordisplay_code">
5959
<code id="error-stack"></code>
60-
</pre></div><div id="root"></div><script src="runtime~main.1db343d140cd02179525.bundle.js"></script><script src="vendors~main.1db343d140cd02179525.bundle.js"></script><script src="main.1db343d140cd02179525.bundle.js"></script></body></html>
60+
</pre></div><div id="root"></div><script src="runtime~main.53eb4e935b55fc68a17b.bundle.js"></script><script src="vendors~main.53eb4e935b55fc68a17b.bundle.js"></script><script src="main.53eb4e935b55fc68a17b.bundle.js"></script></body></html>

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
}
1212
} catch (e) {
1313
console.warn('unable to connect to parent frame for connecting dev tools');
14-
}</script></head><body><div id="root"></div><script src="./sb_dll/storybook_ui_dll.js"></script><script src="runtime~main.67b3c42af12dc2b7ac9d.bundle.js"></script><script src="vendors~main.c7cdde8fdc5d62ae5ce6.bundle.js"></script><script src="main.584ae462a0cb36e05a05.bundle.js"></script></body></html>
14+
}</script></head><body><div id="root"></div><script src="./sb_dll/storybook_ui_dll.js"></script><script src="runtime~main.23a842e0cf9f5bd27e60.bundle.js"></script><script src="vendors~main.cf21e66639e7e7094b5b.bundle.js"></script><script src="main.8a2064d11d740364a590.bundle.js"></script></body></html>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"devDependencies": {
2727
"@babel/cli": "^7.2.0",
2828
"@babel/core": "^7.2.2",
29+
"@babel/plugin-proposal-class-properties": "^7.8.3",
2930
"@babel/plugin-proposal-export-default-from": "^7.2.0",
3031
"@babel/preset-env": "^7.2.0",
3132
"@babel/preset-react": "^7.0.0",

samples/photo_album/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"babel-runtime": "6.26.0",
1313
"case-sensitive-paths-webpack-plugin": "2.1.1",
1414
"chalk": "1.1.3",
15-
"cloudinary-react": "^1.1.4",
15+
"cloudinary-react": "^1.3.1",
1616
"css-loader": "2.1.1",
1717
"dotenv": "4.0.0",
1818
"eslint": "4.18.2",

samples/photo_album/src/components/Photo.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
33
import { Image, Transformation } from 'cloudinary-react';
44
import { url } from '../utils/CloudinaryService';
55
import PhotoThumbnails from './PhotoThumbnails';
6+
import {CloudinaryContext} from 'cloudinary-react';
67

78
class Photo extends Component {
89
constructor(props) {
@@ -64,16 +65,13 @@ class Photo extends Component {
6465
showLess() {
6566
this.setState({ showMore: false });
6667
}
68+
69+
static contextType = CloudinaryContext.contextType;
6770
}
6871

6972
Photo.propTypes = {
7073
context: PropTypes.object,
7174
publicId: PropTypes.string,
7275
};
7376

74-
Photo.contextTypes = {
75-
cloudName: PropTypes.string,
76-
uploadPreset: PropTypes.string,
77-
};
78-
7977
export default Photo;

samples/photo_album/src/components/PhotoList.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { photosUploaded } from '../actions';
77
import Photo from './Photo';
88
import FacebookImage from './FacebookImage';
99
import Introduction from './Introduction';
10+
import {CloudinaryContext} from 'cloudinary-react';
1011

1112
class PhotoList extends Component {
1213
render() {
@@ -69,18 +70,15 @@ class PhotoList extends Component {
6970
}
7071
});
7172
}
73+
74+
static contextType = CloudinaryContext.contextType;
7275
}
7376

7477
PhotoList.propTypes = {
7578
photos: PropTypes.array,
7679
onPhotosUploaded: PropTypes.func,
7780
};
7881

79-
PhotoList.contextTypes = {
80-
cloudName: PropTypes.string,
81-
uploadPreset: PropTypes.string,
82-
};
83-
8482
const PhotoListContainer = connect(
8583
state => ({ photos: state.photos }),
8684
{

samples/photo_album/src/components/PhotosUploader.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import request from 'superagent';
66
import Dropzone from 'react-dropzone';
77
import { photosUploaded, updateUploadedPhoto } from '../actions';
88
import UploadedPhotoStatusContainer from './UploadedPhotosStatus';
9+
import {CloudinaryContext} from "cloudinary-react";
910

1011
class PhotosUploader extends Component {
1112
constructor(props, context) {
@@ -135,6 +136,8 @@ class PhotosUploader extends Component {
135136

136137
this.props.onPhotosUploaded([response.body]);
137138
}
139+
140+
static contextType = CloudinaryContext.contextType;
138141
}
139142

140143
PhotosUploader.propTypes = {
@@ -143,11 +146,6 @@ PhotosUploader.propTypes = {
143146
onPhotosUploaded: PropTypes.func,
144147
};
145148

146-
PhotosUploader.contextTypes = {
147-
cloudName: PropTypes.string,
148-
uploadPreset: PropTypes.string,
149-
};
150-
151149
const PhotosUploaderContainer = connect(
152150
state => state,
153151
{

samples/photo_album/src/components/UploadedPhotosStatus.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
33
import { connect } from 'react-redux';
44
import request from 'superagent';
55
import { deleteUploadedPhoto } from '../actions';
6+
import {CloudinaryContext} from "cloudinary-react";
67

78
class UploadedPhotoStatus extends Component {
89
render() {
@@ -78,18 +79,15 @@ class UploadedPhotoStatus extends Component {
7879
this.props.uploadedPhoto.response.body.public_id
7980
);
8081
}
82+
83+
static contextType = CloudinaryContext.contextType;
8184
}
8285

8386
UploadedPhotoStatus.propTypes = {
8487
uploadedPhoto: PropTypes.object,
8588
onDeleteUploadedPhoto: PropTypes.func,
8689
};
8790

88-
UploadedPhotoStatus.contextTypes = {
89-
cloudName: PropTypes.string,
90-
uploadPreset: PropTypes.string,
91-
};
92-
9391
const UploadedPhotoStatusContainer = connect(
9492
state => state,
9593
{

samples/photo_album/src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ import { Provider } from 'react-redux';
55
import App from './components/App';
66
import PhotosListReducer from './reducers/PhotosListReducer';
77
import UploadedPhotosReducer from './reducers/UploadedPhotosReducer';
8-
import Config from './config/config';
8+
import config from './config/config';
99

1010
const rootReducer = combineReducers({
1111
photos: PhotosListReducer,
1212
uploadedPhotos: UploadedPhotosReducer,
1313
});
1414

1515
const store = createStore(rootReducer);
16+
const {cloud_name, upload_preset} = config;
1617

1718
render(
1819
<Provider store={store}>
19-
<App cloudName={Config.cloud_name}
20-
uploadPreset={Config.upload_preset} />
20+
<App cloudName={cloud_name} uploadPreset={upload_preset}/>
2121
</Provider>,
2222
document.getElementById('root')
2323
);

0 commit comments

Comments
 (0)