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@roothub/react-split-paneitch-scratch-guiiqa-react-multi-split-panekyber-componentsinferno-split-panehippy-uilybycmpskulbot-gui@unifyux/react@zenchef/react-intl-tel-input@teamupstart/react-toolbox@zooshgroup/react-toolbox@zooshgroup/react-toolbox-componentsakid-guiaccessible-react-toolboxarui-feather@cimpress/react-components@graphistry/react-split-pane@253eosam/react-split-pane@harissokoli1/react-intl-tel-input@hapticsynaptic/braceletmaker-gui@cognimbus/react-split-pane@airjam/react-intl-tel-inputscratch-gui-astrosprinkles-uiubervu-react-split-panetile-list-viewtinvif-mobiletraec-reacttowneditor-gui@centreon/react-componentsyes-prop-typeswawu-scratch-gui@koteus/react-split-pane@mvarble/react-gif@ryohey/react-split-pane@reboott/react-split-pane@rexxars/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-starterkitreact-split-panereact-split-pane-altreact-split-pane-hgreact-split-pane-style-fixreact-split-pane-viethuy-21react-split-pane-ocuco
3.2.2

7 years ago

3.2.1

8 years ago

3.2.0

8 years ago

3.1.0

8 years ago

3.0.0

9 years ago

2.0.2

9 years ago

2.0.1

9 years ago

2.0.0

9 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

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago