How to use the prop-types.func function in prop-types

To help you get started, we’ve selected a few prop-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Khan / react-components / js / drag-target.jsx View on Github external
//
// Other extensions:
// * custom styles for global drag and dragOver
// * only respond to certain types of drags (only images for instance)!

const React = require('react');
const createReactClass = require('create-react-class');
const PropTypes = require('prop-types');

const DragTarget = createReactClass({
    propTypes: {
        // All props not listed here are forwarded to the root element without
        // modification.
        onDrop: PropTypes.func.isRequired,
        component: PropTypes.any,  // component type
        shouldDragHighlight: PropTypes.func,
        style: PropTypes.any,
    },
    getDefaultProps: function() {
        return {
            component: "div",
            shouldDragHighlight: () => true,
        };
    },
    getInitialState: function() {
        return {dragHover: false};
    },
    handleDrop: function(e) {
        e.stopPropagation();
        e.preventDefault();
        this.setState({dragHover: false});
        this.props.onDrop(e);
github mongaku / mongaku / src / views / Wrapper.js View on Github external
render() {
        return this.props.children;
    }
}

Wrapper.childContextTypes = {
    lang: PropTypes.string,
    user: PropTypes.any,
    options: PropTypes.any,
    originalUrl: PropTypes.string,

    // Coming from utils.js
    getOtherURL: PropTypes.func,
    URL: PropTypes.func,
    STATIC: PropTypes.func,
    stringNum: PropTypes.func,
    fixedDate: PropTypes.func,
    format: PropTypes.func,
    gettext: PropTypes.func,
    getSource: PropTypes.func,
};

module.exports = Wrapper;
github geosolutions-it / MapStore2 / web / client / components / maps / MapGrid.jsx View on Github external
colProps: PropTypes.object,
        // CALLBACKS
        updateMapMetadata: PropTypes.func,
        editMap: PropTypes.func,
        saveAll: PropTypes.func,
        saveMap: PropTypes.func,
        onDisplayMetadataEdit: PropTypes.func,
        removeThumbnail: PropTypes.func,
        errorCurrentMap: PropTypes.func,
        updateCurrentMap: PropTypes.func,
        detailsSheetActions: PropTypes.object,
        createThumbnail: PropTypes.func,
        deleteThumbnail: PropTypes.func,
        deleteMap: PropTypes.func,
        onShare: PropTypes.func,
        resetCurrentMap: PropTypes.func,
        updatePermissions: PropTypes.func,
        metadataModal: PropTypes.func,
        onUpdateAttribute: PropTypes.func,
        title: PropTypes.node,
        className: PropTypes.string,
        style: PropTypes.object
    };

    static defaultProps = {
        id: "mapstore-maps-grid",
        mapType: 'leaflet',
        bottom: "",
        fluid: true,
        colProps: {
            xs: 12,
            sm: 6
github martinandert / react-translate-component / index.js View on Github external
'use strict';

var React = require('react');
var PropTypes = require('prop-types');
var createReactClass = require('create-react-class');
var Interpolate = require('react-interpolate-component');
var translator = require('counterpart');
var extend = require('object-assign');

var translatorType = PropTypes.shape({
  getLocale:        PropTypes.func,
  onLocaleChange:   PropTypes.func,
  offLocaleChange:  PropTypes.func,
  translate:        PropTypes.func
});

var keyType = PropTypes.oneOfType([
  PropTypes.string,
  PropTypes.arrayOf(PropTypes.string)
]);

var Translate = createReactClass({
  displayName: 'Translate',

  contextTypes: {
    translator: translatorType,
    scope: keyType
  },
github Marwan01 / food-converter / node_modules / react-native / Libraries / Image / Image.android.js View on Github external
/**
   * Invoked on load start
   */
  onLoadStart: PropTypes.func,
  /**
   * Invoked on load error
   */
  onError: PropTypes.func,
  /**
   * Invoked when load completes successfully
   */
  onLoad: PropTypes.func,
  /**
   * Invoked when load either succeeds or fails
   */
  onLoadEnd: PropTypes.func,
  /**
   * Used to locate this view in end-to-end tests.
   */
  testID: PropTypes.string,
  /**
   * The mechanism that should be used to resize the image when the image's dimensions
   * differ from the image view's dimensions. Defaults to `auto`.
   *
   * See https://facebook.github.io/react-native/docs/image.html#resizemethod
   */
  resizeMethod: PropTypes.oneOf(['auto', 'resize', 'scale']),
  /**
   * Determines how to resize the image when the frame doesn't match the raw
   * image dimensions.
   *
   * See https://facebook.github.io/react-native/docs/image.html#resizemode
github leafo / sightreading.training / static / js / components / flash_cards / chord_identification_exercise.es6 View on Github external
static notes = ["C", "D", "E", "F", "G", "A", "B"]
  static chordTypes = ["M", "m", "dim"]

  static propTypes = {
    settings: types.object.isRequired,
  }

  static defaultSettings() {
    return {
      keySignatures: { "0": true }
    }
  }

  static ExerciseOptions = class extends React.PureComponent {
    static propTypes = {
      updateSettings: types.func.isRequired,
    }

    render() {
      let settings = this.props.currentSettings

      return <div>
        <section>
          <h4>Key signature</h4>
          {KeySignature.allKeySignatures().map(ks =&gt; {
            let count = "" + ks.count
            return <label>
              <input checked="{settings.keySignatures[count]">
                  this.props.updateSettings({
                    ...settings,</label></section></div>
github zanata / zanata-platform / server / zanata-frontend / src / app / containers / ProjectVersion / TMMergeProjectTMOptions.js View on Github external
validationState='warning' disabled={disabled}&gt;
      <span>I will need to review it</span><br>
      
      
        <a role="button">
          
        </a>
      
    
    {reject}
  
}
MetaDataCheckOption.propTypes = {
  name: PropTypes.string.isRequired,
  value: PropTypes.oneOf([IGNORE_CHECK, FUZZY, REJECT]).isRequired,
  callback: PropTypes.func.isRequired,
  hasReject: PropTypes.bool,
  disabled: PropTypes.bool.isRequired
}

class TMMergeProjectTMOptions extends Component {
  static propTypes = {
    ...TMMergeOptionsValuePropType,
    ...TMMergeOptionsCallbackPropType,
    disableDifferentProjectOption: PropTypes.bool.isRequired,
    disabled: PropTypes.bool.isRequired
  }
  onDifferentProjectChange = (value) =&gt; () =&gt; {
    this.props.onDifferentProjectChange(value)
  }
  onDifferentDocIdChange = (value) =&gt; () =&gt; {
    this.props.onDifferentDocIdChange(value)
github lieryang / EYDouYin / EYDouYin / node_modules / react-native / Libraries / Components / TextInput / TextInput.js View on Github external
* Changed text is passed as an argument to the callback handler.
     */
    onChangeText: PropTypes.func,
    /**
     * Callback that is called when the text input's content size changes.
     * This will be called with
     * `{ nativeEvent: { contentSize: { width, height } } }`.
     *
     * Only called for multiline text inputs.
     */
    onContentSizeChange: PropTypes.func,
    onTextInput: PropTypes.func,
    /**
     * Callback that is called when text input ends.
     */
    onEndEditing: PropTypes.func,
    /**
     * Callback that is called when the text input selection is changed.
     * This will be called with
     * `{ nativeEvent: { selection: { start, end } } }`.
     */
    onSelectionChange: PropTypes.func,
    /**
     * Callback that is called when the text input's submit button is pressed.
     * Invalid if `multiline={true}` is specified.
     */
    onSubmitEditing: PropTypes.func,
    /**
     * Callback that is called when a key is pressed.
     * This will be called with `{ nativeEvent: { key: keyValue } }`
     * where `keyValue` is `'Enter'` or `'Backspace'` for respective keys and
     * the typed-in character otherwise including `' '` for space.
github navikt / nav-frontend-moduler / packages / node_modules / nav-frontend-skjema / src / radio.tsx View on Github external
/**
     * Label for radiobutton
     */
    label: PT.node.isRequired,
    /**
     * Id for radiobutton, hvis id ikke er satt brukes en tilfeldig guid
     */
    id: PT.string,
    /**
     * Name for radiobutton gruppe
     */
    name: PT.string.isRequired,
    /**
     * Referanse til selve radioknappen. Brukes for eksempel til å sette fokus
     */
    radioRef: PT.func
};

(Radio as React.ComponentClass).defaultProps = {
    className: undefined,
    id: undefined,
    radioRef: undefined
};

export default Radio;
github shine-design / shine-design / src / components / Form / index.js View on Github external
onSubmit={this._onSubmit}
        {...attributes}
      &gt;
        {_children}
      
    );
  }
}

Form.propTypes = {
  /** 表单提交回调函数,无论表单校验是否通过均会触发,第一个参数为提交事件,第二个参数为校验结果 */
  onSubmit: PropTypes.func,
  /** 表单校验通过回调函数,当表单提交且校验通过时触发该函数,第一个参数为提交事件 */
  onSuccess: PropTypes.func,
  /** 表单校验失败回调函数,当表单提交且校验失败时触发该函数,第一个参数为提交事件,第二个参数为校验结果 */
  onError: PropTypes.func,
  /** 用户自定义修饰符 */
  className: PropTypes.string,
  /** 用户自定义属性 */
  attributes: PropTypes.object,
};

Form.defaultProps = {
  onSubmit: undefined,
  onSuccess: undefined,
  onError: undefined,
  className: '',
  attributes: {},
};

/** 表单项组件 */
Form.Item = Item;