-
Notifications
You must be signed in to change notification settings - Fork 215
create react sample application #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -0,0 +1,264 @@ | |||
'use strict'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you remember why you needed to eject Webpack's config?
Could the sample app work without ejecting the config file?
If not, please highlight in the README.md the reasons for ejecting Webpack config in this sample
<noscript> | ||
You need to enable JavaScript to run this app. | ||
</noscript> | ||
<script src="//widget.cloudinary.com/global/all.js" type="text/javascript"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment to the README about the different upload options and how to configure them, add a comment here about why this file is optionally included
|
||
export default class Cloudinary { | ||
|
||
static url(publicId, options) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need a class that has only static methods?
Why not export the functions independently and let consumers import only what they need?
Then you can rename the file to CloudinaryService
and use it as
import { url } from './CloudinaryService.js'
@@ -0,0 +1,54 @@ | |||
import Cloudinary from "../Cloudinary"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code style isn't consistent. Some files import with a single quote, others with double quotes.
What about adding a .editorconfig file for consistency?
And maybe use prettier
too?
publicId: publicId | ||
}); | ||
|
||
export const fetchPhotos = (cloudName) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be in the actions file, it's a utility method. It should move the CloudinaryService.js
(the name I proposed a few comments ago)
const index = photos.findIndex(current => current.public_id === action.publicId); | ||
return [...photos.slice(0, index), ...photos.slice(index + 1)]; | ||
default: | ||
return photos; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should return an immutable object
return [...uploadedPhotos.slice(0, index), ...uploadedPhotos.slice(index + 1)]; | ||
} | ||
default: | ||
return uploadedPhotos; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should return an immutable object
uploadedPhotos.map(current => current.id === newPhoto.id ? {...current, ...newPhoto} : current); | ||
} | ||
case 'DELETE_UPLOADED_PHOTO': { | ||
const index = uploadedPhotos.findIndex(current => current.response.body.public_id === action.publicId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Array.filter
|
||
return (index === -1) ? | ||
[newPhoto, ...uploadedPhotos] : | ||
uploadedPhotos.map(current => current.id === newPhoto.id ? {...current, ...newPhoto} : current); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You already have the index of the changed item, why iterate again, and not change that index?
samples/photo_album/README.md
Outdated
@@ -0,0 +1,2229 @@ | |||
This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add to the beginning of this generated README a description of the functionality of this sample and any other important information the reader might need
import { NavLink } from 'react-router-dom'; | ||
import { connect } from 'react-redux'; | ||
import request from 'superagent'; | ||
import Dropzone from 'react-dropzone'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Package is not listed in package.json/yarn.lock
import PropTypes from 'prop-types'; | ||
import {connect} from "react-redux"; | ||
import { connect } from 'react-redux'; | ||
import request from 'superagent'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Package is not listed in package.json/yarn.lock
Take a look at our documentation of{' '} | ||
<a | ||
href="https://cloudinary.com/documentation/image_transformations" | ||
target="_blank" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error in console - Line 51: Using target="_blank" without rel="noopener noreferrer" is a security risk: see https://mathiasbynens.github.io/rel-noopener react/jsx-no-target-blank
samples/photo_album/src/index.js
Outdated
render( | ||
<Provider store={store}> | ||
<AppContainer cloudName='dvxpdqpjj' uploadPreset='hvs8orho'/> | ||
<AppContainer cloudName="danashalev" uploadPreset="hvs8orho" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't have your credentials. Read cloud name + upload preset from a config file provided by the user (you can create a sample config file with placeholders).
y='12'> | ||
</Transformation> | ||
<Video | ||
sourceTypes={'webm'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why limit to webm? The video can't play on Safari
const PhotosListReducer = (photos = [], action) => { | ||
switch (action.type) { | ||
case 'PHOTOS_FETCHED': | ||
return action.photos; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment was probably overlooked. The returned object should be immutable (at least return a copy of action.photos)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added one more comment
}; | ||
|
||
const AppContainer = connect( | ||
() => {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should return an object. Creates the following error in browser console:
mapStateToProps() in Connect(App) must return a plain object. Instead received undefined.
Create react sample application over cloudinary react sdk