3.2.2 • Published 7 years ago

react-style-proptype v3.2.2

Weekly downloads
250,213
License
MIT
Repository
github
Last release
7 years ago

Validates style objects by ensuring the keys are valid css property names (in camelcase form).

var stylePropType = require('react-style-proptype');

var Comp = React.createClass({
  propTypes: {
    myStyle: stylePropType,
  },
  render(){ ... }
});

You can use stylePropType.isRequired similar to the built in proptypes.

Flow

We also expose a flow type definition. It doesn't use an 'exact' type definition due to a bug in flow, so it'll allow invalid properties. The main purpose of this type is to improve the editor experience for custom components that accept a style prop.

import { type Style } from 'react-style-proptype/src/Style.flow.js';

type Props = {
  style: Style,
};

Arrays

With react-native styles can be passed an array of objects. You can use this variant with stylePropTypes.supportingArrays.

Removing in production

While prop-types aren't executed in production, they still take up bundle size. This is true of both the official prop-types package and react-style-proptype.

babel-plugin-transform-react-remove-prop-types can be used to completely remove prop-types, including the one from react-style-proptype.

Example .babelrc

{
  "presets": ["env", "react"],
  "plugins": [
    [
      "transform-react-remove-prop-types",
      {
        "removeImport": true,
        "additionalLibraries": ["react-style-proptype"]
      }
    ]
  ]
}
@that1matt/react-toolboxmircoai-guiinsync-stageplayerscratch-gui-freerange@web-uni/uni-uiteasim-samplesglitchyscratch-gui@everything-registry/sub-chunk-2615blockzie-guiwoobixlvg-utilsxl-react-split-panescratch-guisuny-guivic-react-intl-tel-input@cybergenios/scratch-gui@roothub/react-split-paneitch-scratch-guiiqa-react-multi-split-panekyber-componentsscratch-gui-astrosprinkles-uiubervu-react-split-panetile-list-viewtinvif-mobiletraec-reacttowneditor-gui@airjam/react-intl-tel-input@andrewsantarin/react-intl-tel-input@andrewray/react-split-pane@cimpress/react-components@centreon/react-components@253eosam/react-split-pane@cognimbus/react-split-pane@dewesoft-web/uiyes-prop-typeswawu-scratch-gui@healthadvisor/react-toolbox@hapticsynaptic/braceletmaker-gui@harissokoli1/react-intl-tel-input@foo-software/react-toolbox@koteus/react-split-pane@luchanso/arui-feather@mvarble/react-gif@maposia/react-split-pane@mattbark/react-toolbox@nixtus/react-flextable@matveyneyman/react-split-pane@graphistry/react-split-pane@noriaki/react-timer-component@raspberrypifoundation/scratch-gui@ryohey/react-split-pane@quanxiaoxiao/photo-display@reboott/react-split-pane@rexxars/react-split-pane@nxtedition/react-toolbox@opuscapita/react-splitpane@skillx/react-intl-tel-input@soof-golan/react-split-panemscratchmood-react-toolboxmng-react-toolboxminecraft-storeys-scratch-guiopenblock-guiscalez-guiscratch-arduino-guiscratch-gui-cntscratch-gui-groundhogscratch-gui-liaoscratch-gui-okagvscratch-gui-pearupscratchhw-guireact-bizreact-bs4gridrobopro-guireact-letter-morphreact-ken-burns-videoreact-isometric-gridreact-isometric-grid-tsreact-intl-tel-inputreact-intl-tel-input-18react-intl-tel-input-2react-intl-tel-input-braianreact-intl-tel-input-dsareact-intl-tel-input-fixedreact-intl-tel-input-inhandreact-intl-tel-input-itkreact-intl-tel-input-muireact-intl-tel-input-ueatreact-intl-tel-input-wrapperreact-intl-tel-samplereact-intl-phone-inputreact-image-viewerreact-int-phone-input-accessibilityreact-native-style-prop-typereact-pane-splitlinepool-scratch-guishan-scratch-guireact-responsive-tablereact-redux-webpack2-starterkit
3.2.2

7 years ago

3.2.1

7 years ago

3.2.0

7 years ago

3.1.0

8 years ago

3.0.0

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.4.0

9 years ago

1.3.2

9 years ago

1.3.1

9 years ago

1.3.0

9 years ago

1.2.0

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago