3.2.2 • Published 6 years ago

react-style-proptype v3.2.2

Weekly downloads
250,213
License
MIT
Repository
github
Last release
6 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-guiscratch-gui@everything-registry/sub-chunk-2615delightmom-scratch-gui@dewesoft-web/uiflex-stepperflex-react-stepperfunctional-formsdraftjs-formsy-inputdragon-drop-uielectrum-arc@hapticsynaptic/braceletmaker-gui@harissokoli1/react-intl-tel-input@healthadvisor/react-toolboxiqa-react-multi-split-paneinferno-split-pane@graphistry/react-split-paneitch-scratch-guidt-react-toolbox@centreon/react-components@cimpress/react-components@foo-software/react-toolboxhippy-uiopenblock-guikulbot-guiscratch-gui-astro@zooshgroup/react-toolbox@zooshgroup/react-toolbox-components@soof-golan/react-split-paneclipcc-guicodevider-scratch-guiarui-featherxlvg-utilsxl-react-split-paneyes-prop-types@zenchef/react-intl-tel-inputaccessible-react-toolboxwoobiwawu-scratch-gui@253eosam/react-split-pane@andrewray/react-split-pane@andrewsantarin/react-intl-tel-inputakid-guicarousel-native2.0@teamupstart/react-toolboxtinvif-mobile@team-monolith/scratch-guitile-list-viewtraec-reacttowneditor-gui@skillx/react-intl-tel-inputsuny-guisprinkles-ui@shabinpshams/react-intl-tel-inputvic-react-intl-tel-inputubervu-react-split-pane@unifyux/reactctms-react-split-pane@cybergenios/scratch-gui@cognimbus/react-split-paneconvose-ui-webreact-bs4gridreact-biz@koteus/react-split-pane@luchanso/arui-feather@maposia/react-split-pane@matveyneyman/react-split-panelybycmps@mattbark/react-toolbox@mvarble/react-gifreact-int-phone-input-accessibilityreact-intl-phone-inputreact-intl-tel-input-18react-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-tel-inputreact-intl-tel-input-2@nixtus/react-flextablemscratchreact-timer-componentreact-toolbox-strict-modereact-toolbox-usmanscreact-toolbox2react-toolbox-betareact-toolboxreact-toolbox-gmdreact-toolbox-gmdb
3.2.2

6 years ago

3.2.1

6 years ago

3.2.0

6 years ago

3.1.0

7 years ago

3.0.0

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.4.0

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.0

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago