Skip to content

Commit

Permalink
feat: Add deprecation warnings for some props (#364)
Browse files Browse the repository at this point in the history
In the next major release some props will be deprecated.
In order to smoothen the migration process deprecation warnings were added.
  • Loading branch information
okonet committed Feb 23, 2017
1 parent 6179110 commit 0cc351d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 10 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"react": "^0.14.0 || ^15.0.0"
},
"dependencies": {
"attr-accept": "^1.0.3"
"attr-accept": "^1.0.3",
"react-is-deprecated": "^0.1.2"
},
"devDependencies": {
"babel-cli": "^6.9.0",
Expand Down
56 changes: 47 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint prefer-template: 0 */
import React from 'react';
import accepts from 'attr-accept';
import { deprecate } from 'react-is-deprecated';
import getDataTransferItems from './getDataTransferItems';

const supportMultiple = (typeof document !== 'undefined' && document && document.createElement) ?
Expand Down Expand Up @@ -325,16 +326,47 @@ Dropzone.propTypes = {
onDragOver: React.PropTypes.func,
onDragLeave: React.PropTypes.func,

// Contents of the dropzone
children: React.PropTypes.oneOfType([
React.PropTypes.node,
React.PropTypes.func
]), // Contents of the dropzone
style: React.PropTypes.object, // CSS styles to apply
activeStyle: React.PropTypes.object, // CSS styles to apply when drop will be accepted
rejectStyle: React.PropTypes.object, // CSS styles to apply when drop will be rejected
className: React.PropTypes.string, // Optional className
activeClassName: React.PropTypes.string, // className for accepted state
rejectClassName: React.PropTypes.string, // className for rejected state
]),

// CSS styles to apply
style: deprecate(
React.PropTypes.object,
'Prop style is deprecated. Use function as children to style dropzone and its contents.'
),

// CSS styles to apply when drop will be accepted
activeStyle: deprecate(
React.PropTypes.object,
'Prop activeStyle is deprecated. Use function as children to style dropzone and its contents.'
),

// CSS styles to apply when drop will be rejected
rejectStyle: deprecate(
React.PropTypes.object,
'Prop rejectStyle is deprecated. Use function as children to style dropzone and its contents.'
),

// Optional className
className: deprecate(
React.PropTypes.string,
'Prop className is deprecated. Use function as children to style dropzone and its contents.'
),

// className for accepted state
activeClassName: deprecate(
React.PropTypes.string,
'Prop activeClassName is deprecated. Use function as children to style dropzone and its contents.'
),

// className for rejected state
rejectClassName: deprecate(
React.PropTypes.string,
'Prop rejectClassName is deprecated. Use function as children to style dropzone and its contents.'
),

disablePreview: React.PropTypes.bool, // Enable/disable preview generation
disableClick: React.PropTypes.bool, // Disallow clicking on the dropzone container to open file dialog
Expand All @@ -344,8 +376,14 @@ Dropzone.propTypes = {
multiple: React.PropTypes.bool, // Allow dropping multiple files
accept: React.PropTypes.string, // Allow specific types of files. See https://github.com/okonet/attr-accept for more information
name: React.PropTypes.string, // name attribute for the input tag
maxSize: React.PropTypes.number,
minSize: React.PropTypes.number
maxSize: deprecate(
React.PropTypes.number,
'Prop maxSize is deprecated and will be removed in the next major release'
),
minSize: deprecate(
React.PropTypes.number,
'Prop minSize is deprecated and will be removed in the next major release'
)
};

export default Dropzone;

2 comments on commit 0cc351d

@rijk
Copy link

@rijk rijk commented on 0cc351d Mar 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why will maxSize and minSize be deprecated??

@okonet
Copy link
Collaborator Author

@okonet okonet commented on 0cc351d Mar 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of #321

Please sign in to comment.