Skip to content

Commit

Permalink
use create-react-app and prop-types (formsy#219)
Browse files Browse the repository at this point in the history
this removes the warnings when using React 15.5.0 or higher, since using React.createClass or React.PropTypes are deprecated
  • Loading branch information
ulich authored and mbrookes committed Jun 20, 2017
1 parent f2601b3 commit 6845c21
Show file tree
Hide file tree
Showing 12 changed files with 4,444 additions and 77 deletions.
5 changes: 3 additions & 2 deletions examples/webpack-example/src/app/Main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import createClass from 'create-react-class';
import Formsy from 'formsy-react';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
Expand All @@ -8,14 +9,14 @@ import MenuItem from 'material-ui/MenuItem';
import { FormsyCheckbox, FormsyDate, FormsyRadio, FormsyRadioGroup,
FormsySelect, FormsyText, FormsyTime, FormsyToggle, FormsyAutoComplete } from 'formsy-material-ui/lib';

const Main = React.createClass({
const Main = createClass({

/**
* As an alternative to `MuiThemeProvider` you can add a theme directly into context.
* See the [Material-UI themes](http://www.material-ui.com/#/customization/themes) docs for details.
*
* childContextTypes: {
* muiTheme: React.PropTypes.object,
* muiTheme: PropTypes.object,
* },
* getChildContext(){
* return {
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"formsy-react": "^0.19.0",
"material-ui": "^0.17.0",
"react": "^15.0.0",
"react-dom": "^15.0.0"
"react-dom": "^15.0.0",
"prop-types": "^15.5.7",
"create-react-class": "^15.5.0"
},
"devDependencies": {
"babel-cli": "^6.3.17",
Expand Down
18 changes: 10 additions & 8 deletions src/FormsyAutoComplete.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import React from 'react';
import createClass from 'create-react-class';
import PropTypes from 'prop-types';
import keycode from 'keycode';
import Formsy from 'formsy-react';
import AutoComplete from 'material-ui/AutoComplete';
import { setMuiComponentAndMaybeFocus } from 'formsy-react/src/utils';

const FormsyAutoComplete = React.createClass({
const FormsyAutoComplete = createClass({

propTypes: {
defaultValue: React.PropTypes.any,
name: React.PropTypes.string.isRequired,
onBlur: React.PropTypes.func,
onChange: React.PropTypes.func,
onFocus: React.PropTypes.func,
onKeyDown: React.PropTypes.func,
value: React.PropTypes.any,
defaultValue: PropTypes.any,
name: PropTypes.string.isRequired,
onBlur: PropTypes.func,
onChange: PropTypes.func,
onFocus: PropTypes.func,
onKeyDown: PropTypes.func,
value: PropTypes.any,
},

mixins: [Formsy.Mixin],
Expand Down
16 changes: 9 additions & 7 deletions src/FormsyCheckbox.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import React from 'react';
import createClass from 'create-react-class';
import PropTypes from 'prop-types';
import Formsy from 'formsy-react';
import Checkbox from 'material-ui/Checkbox';
import { setMuiComponentAndMaybeFocus } from './utils';

const FormsyCheckbox = React.createClass({
const FormsyCheckbox = createClass({

propTypes: {
defaultChecked: React.PropTypes.bool,
name: React.PropTypes.string.isRequired,
onChange: React.PropTypes.func,
validationError: React.PropTypes.string,
validationErrors: React.PropTypes.object,
validations: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.object]),
defaultChecked: PropTypes.bool,
name: PropTypes.string.isRequired,
onChange: PropTypes.func,
validationError: PropTypes.string,
validationErrors: PropTypes.object,
validations: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
},

mixins: [Formsy.Mixin],
Expand Down
20 changes: 11 additions & 9 deletions src/FormsyDate.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import React from 'react';
import createClass from 'create-react-class';
import PropTypes from 'prop-types';
import Formsy from 'formsy-react';
import DatePicker from 'material-ui/DatePicker';
import { setMuiComponentAndMaybeFocus } from './utils';

const FormsyDate = React.createClass({
const FormsyDate = createClass({

propTypes: {
defaultDate: React.PropTypes.object,
name: React.PropTypes.string.isRequired,
onChange: React.PropTypes.func,
requiredError: React.PropTypes.string,
validationError: React.PropTypes.string,
validationErrors: React.PropTypes.object,
validations: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.object]),
value: React.PropTypes.object,
defaultDate: PropTypes.object,
name: PropTypes.string.isRequired,
onChange: PropTypes.func,
requiredError: PropTypes.string,
validationError: PropTypes.string,
validationErrors: PropTypes.object,
validations: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
value: PropTypes.object,
},

mixins: [Formsy.Mixin],
Expand Down
4 changes: 2 additions & 2 deletions src/FormsyRadio.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import createClass from 'create-react-class';
import Formsy from 'formsy-react';

const FormsyRadio = React.createClass({
const FormsyRadio = createClass({

mixins: [Formsy.Mixin],

Expand Down
20 changes: 11 additions & 9 deletions src/FormsyRadioGroup.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import React from 'react';
import createClass from 'create-react-class';
import PropTypes from 'prop-types';
import Formsy from 'formsy-react';
import { RadioButtonGroup, RadioButton } from 'material-ui/RadioButton';
import { setMuiComponentAndMaybeFocus } from './utils';

const FormsyRadioGroup = React.createClass({
const FormsyRadioGroup = createClass({

propTypes: {
children: React.PropTypes.node,
defaultSelected: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.number, React.PropTypes.bool]),
name: React.PropTypes.string.isRequired,
onChange: React.PropTypes.func,
validationError: React.PropTypes.string,
validationErrors: React.PropTypes.object,
validations: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.object]),
value: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.number, React.PropTypes.bool]),
children: PropTypes.node,
defaultSelected: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
name: PropTypes.string.isRequired,
onChange: PropTypes.func,
validationError: PropTypes.string,
validationErrors: PropTypes.object,
validations: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
},

mixins: [Formsy.Mixin],
Expand Down
20 changes: 11 additions & 9 deletions src/FormsySelect.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import React from 'react';
import createClass from 'create-react-class';
import PropTypes from 'prop-types';
import Formsy from 'formsy-react';
import SelectField from 'material-ui/SelectField';
import { setMuiComponentAndMaybeFocus } from './utils';

const FormsySelect = React.createClass({
const FormsySelect = createClass({

propTypes: {
children: React.PropTypes.node,
name: React.PropTypes.string.isRequired,
onChange: React.PropTypes.func,
requiredError: React.PropTypes.string,
validationError: React.PropTypes.string,
validationErrors: React.PropTypes.object,
validations: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.object]),
value: React.PropTypes.any,
children: PropTypes.node,
name: PropTypes.string.isRequired,
onChange: PropTypes.func,
requiredError: PropTypes.string,
validationError: PropTypes.string,
validationErrors: PropTypes.object,
validations: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
value: PropTypes.any,
},

mixins: [Formsy.Mixin],
Expand Down
32 changes: 17 additions & 15 deletions src/FormsyText.jsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
import React from 'react';
import createClass from 'create-react-class';
import PropTypes from 'prop-types';
import keycode from 'keycode';
import Formsy from 'formsy-react';
import TextField from 'material-ui/TextField';
import { setMuiComponentAndMaybeFocus, debounce } from './utils';

const FormsyText = React.createClass({
const FormsyText = createClass({

propTypes: {
defaultValue: React.PropTypes.any,
name: React.PropTypes.string.isRequired,
onBlur: React.PropTypes.func,
onChange: React.PropTypes.func,
onKeyDown: React.PropTypes.func,
requiredError: React.PropTypes.string,
underlineFocusStyle: React.PropTypes.object,
underlineStyle: React.PropTypes.object,
updateImmediately: React.PropTypes.bool,
validationColor: React.PropTypes.string,
validationError: React.PropTypes.string,
validationErrors: React.PropTypes.object,
validations: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.object]),
value: React.PropTypes.any,
defaultValue: PropTypes.any,
name: PropTypes.string.isRequired,
onBlur: PropTypes.func,
onChange: PropTypes.func,
onKeyDown: PropTypes.func,
requiredError: PropTypes.string,
underlineFocusStyle: PropTypes.object,
underlineStyle: PropTypes.object,
updateImmediately: PropTypes.bool,
validationColor: PropTypes.string,
validationError: PropTypes.string,
validationErrors: PropTypes.object,
validations: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
value: PropTypes.any,
},

mixins: [Formsy.Mixin],
Expand Down
18 changes: 10 additions & 8 deletions src/FormsyTime.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import React from 'react';
import createClass from 'create-react-class';
import PropTypes from 'prop-types';
import Formsy from 'formsy-react';
import TimePicker from 'material-ui/TimePicker';
import { setMuiComponentAndMaybeFocus } from './utils';

const FormsyTime = React.createClass({
const FormsyTime = createClass({

propTypes: {
defaultTime: React.PropTypes.object,
name: React.PropTypes.string.isRequired,
onChange: React.PropTypes.func,
validationError: React.PropTypes.string,
validationErrors: React.PropTypes.object,
validations: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.object]),
value: React.PropTypes.object,
defaultTime: PropTypes.object,
name: PropTypes.string.isRequired,
onChange: PropTypes.func,
validationError: PropTypes.string,
validationErrors: PropTypes.object,
validations: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
value: PropTypes.object,
},

mixins: [Formsy.Mixin],
Expand Down
16 changes: 9 additions & 7 deletions src/FormsyToggle.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import React from 'react';
import createClass from 'create-react-class';
import PropTypes from 'prop-types';
import Formsy from 'formsy-react';
import Toggle from 'material-ui/Toggle';
import { setMuiComponentAndMaybeFocus } from './utils';

const FormsyToggle = React.createClass({
const FormsyToggle = createClass({

propTypes: {
defaultToggled: React.PropTypes.bool,
name: React.PropTypes.string.isRequired,
onChange: React.PropTypes.func,
validationError: React.PropTypes.string,
validationErrors: React.PropTypes.object,
validations: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.object]),
defaultToggled: PropTypes.bool,
name: PropTypes.string.isRequired,
onChange: PropTypes.func,
validationError: PropTypes.string,
validationErrors: PropTypes.object,
validations: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
},

mixins: [Formsy.Mixin],
Expand Down
Loading

0 comments on commit 6845c21

Please sign in to comment.