How to use the prop-types.func.isRequired 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 veritone / veritone-sdk / packages / veritone-react-common / src / components / ContentTemplates / ContentTemplateForm / index.js View on Github external
id: string,
        name: string.isRequired,
        status: string,
        definition: objectOf(any)
      })
    ).isRequired,
    initialTemplates: arrayOf(
      shape({
        id: string,
        name: string.isRequired,
        status: string,
        definition: objectOf(any),
        data: objectOf(any)
      })
    ),
    onSubmit: func.isRequired
  };

  static defaultProps = {
    initialTemplates: []
  };

  state = {
    contentTemplates: []
  };

  // eslint-disable-next-line react/sort-comp
  UNSAFE_componentWillMount() {
    const newState = {
      contentTemplates: [...this.props.initialTemplates]
    };
    newState.contentTemplates.forEach(template => (template.guid = guid()));
github veritone / veritone-sdk / packages / veritone-react-common / src / components / FilePicker / UrlUploader / index.js View on Github external
import React, { Component } from 'react';
import FormControl from '@material-ui/core/FormControl';
import Input from '@material-ui/core/Input';
import InputLabel from '@material-ui/core/InputLabel';
import mime from 'mime-types';
import { func, arrayOf, string } from 'prop-types';

import styles from './styles.scss';

class UrlUploader extends Component {
  static propTypes = {
    onUpload: func.isRequired,
    acceptedFileTypes: arrayOf(string)
  };

  static defaultProps = {
    acceptedFileTypes: []
  };

  state = {
    image: '',
    fetchingImage: false,
    uploadError: false
  };

  preventInput = evt => {
    // todo: a "retrieve" button so we can have manual input without pasting
    evt.preventDefault();
github appbaseio / dashboard / src / pages / CredentialsPage / index.js View on Github external
);
	}
}
Credentials.defaultProps = {
	isLoading: false,
	isDeleting: false,
};
Credentials.propTypes = {
	appName: string.isRequired,
	plan: string.isRequired,
	appId: string.isRequired,
	permissions: array.isRequired,
	fetchPermissions: func.isRequired,
	handleCreatePermission: func.isRequired,
	handleDeletePermission: func.isRequired,
	handleEditPermission: func.isRequired,
	isOwner: bool.isRequired,
	isLoading: bool,
	isDeleting: bool,
	errors: array.isRequired,
	handleDeleteApp: func.isRequired,
};
const mapStateToProps = state => {
	const appOwner = get(getAppInfoByName(state), 'owner');
	const userEmail = get(state, 'user.data.email');
	const appPermissions = getAppPermissionsByName(state);
	const planState = getAppPlanByName(state);
	return {
		appName: get(state, '$getCurrentApp.name'),
		plan: get(planState, 'plan'),
		appId: get(state, '$getCurrentApp.id'),
github AndreMiras / etheroll / src / components / ValueSlider.jsx View on Github external
type="number"
          className="form-control"
          onChange={e => updateValue(Number(e.target.value))}
          value={formattedValue}
        />
        {addon}
      
      <div>
        
      </div>
    
  );
}
ValueSlider.propTypes = {
  value: number.isRequired,
  updateValue: func.isRequired,
  step: number,
  min: number,
  max: number,
  addonText: string,
  toFixedDigits: number,
};
ValueSlider.defaultProps = {
  step: 1,
  min: 0,
  max: 100,
  addonText: null,
  toFixedDigits: null,
};

export default ValueSlider;
github open-apparel-registry / open-apparel-registry / src / app / src / components / FilterSidebar.jsx View on Github external
return (
            <div style="{filterSidebarStyles.controlPanelStyles}">
                {header}
                {tabBar}
                {insetComponent}
            </div>
        );
    }
}

FilterSidebar.propTypes = {
    activeFilterSidebarTab: oneOf(Object.values(filterSidebarTabsEnum)).isRequired,
    makeGuideTabActive: func.isRequired,
    makeSearchTabActive: func.isRequired,
    makeFacilitiesTabActive: func.isRequired,
    fetchFilterOptions: func.isRequired,
    fetchContributors: func.isRequired,
    fetchContributorTypes: func.isRequired,
    fetchCountries: func.isRequired,
    contributorsData: contributorOptionsPropType.isRequired,
    contributorTypesData: contributorTypeOptionsPropType.isRequired,
    countriesData: countryOptionsPropType.isRequired,
    vectorTileFeatureIsActive: bool.isRequired,
    fetchingFeatureFlags: bool.isRequired,
};

function mapStateToProps({
    ui: {
        activeFilterSidebarTab,
github abarriel / Hypertube / src / client / components / CheckBoxSelect / index.js View on Github external
))}
    
  
);

CheckBoxSelect.propTypes = {
  checked: array.isRequired,
  handleChangeChecked: func.isRequired,
  updateFilterMovies: func.isRequired,
};

const actions = { updateFilterMovies };
const mapDispatchToProps = dispatch =&gt; bindActionCreators(actions, dispatch);

const enhance = compose(
  connect(null, mapDispatchToProps),
  withStateHandlers(
    {
      checked: [],
    },
    {
      handleChangeChecked: ({ checked }) =&gt; (label, wasChecked) =&gt; {
        if (label === 'All') {
          return ({ checked: [label] });
        }
github ansible / awx / awx / ui_next / src / components / Lookup / OrganizationLookup.jsx View on Github external
value={value}
        onBlur={onBlur}
        onLookupSave={onChange}
        getItems={getOrganizations}
        required={required}
        sortedColumnKey="name"
      /&gt;
    
  );
}

OrganizationLookup.propTypes = {
  helperTextInvalid: string,
  isValid: bool,
  onBlur: func,
  onChange: func.isRequired,
  required: bool,
  value: Organization,
};

OrganizationLookup.defaultProps = {
  helperTextInvalid: '',
  isValid: true,
  onBlur: () =&gt; {},
  required: false,
  value: null,
};

export default withI18n()(OrganizationLookup);
export { OrganizationLookup as _OrganizationLookup };
github Jordaneisenburger / fallback-studio / src / pwa-studio / packages / peregrine / lib / List / items.js View on Github external
};

/**
 * props for {@link Items}
 *
 * @typedef props
 *
 * @property {func} getItemKey item key value getter
 * @property {array | object} initialSelection A single or list of objects that should start off selected
 * @property {iterable} items An iterable that yields `[key, item]` pairs such as an ES2015 Map
 * @property {func} onSelectionChange A callback that fires when the selection state changes
 * @property {func | string} renderItem A render prop for the list item elements. A tagname string, such as `"div"`, is also valid
 * @property {checkbox | radio} selectionModel A string corresponding to a selection model
 */
Items.propTypes = {
    getItemKey: func.isRequired,
    initialSelection: oneOfType([array, object]),
    items: iterable.isRequired,
    onSelectionChange: func,
    renderItem: oneOfType([func, string]),
    selectionModel: oneOf(['checkbox', 'radio'])
};

/**
 * default props for {@link Items}
 *
 * @typedef @defaultProps
 */
Items.defaultProps = {
    getItemKey: ({ id }) => id,
    selectionModel: 'radio'
};
github FlowCI / flow-web / src / views / Admin / Agents / List / agents.js View on Github external
remove: actions.remove,
    alert: alertActions.alert,
  }, dispatch)
}

export class AdminAgentView extends Component {
  static propTypes = {
    agents: list.isRequired,
    loading: bool,

    query: func.isRequired,
    stop: func.isRequired,
    close: func.isRequired,
    remove: func.isRequired,
    alert: func.isRequired,
    i18n: func.isRequired,
  }

  static defaultProps = {
    i18n: createI18n(language).createChild('list'),
  }

  state = {
    category: 'ALL',
    openConfirm: false,
    openConfig: false,
  }

  componentDidMount () {
    const { query } = this.props
    query()
    this.isMount = true
github chandlerprall / insula / examples / todo / views / NewTodoInput.js View on Github external
function NewTodoInput({addTodo, nextTodo, updateTodo}) {
    return (
        <div>
            <input value="{nextTodo}" type="text"> updateTodo(e.target.value)} placeholder="new todo item"/&gt;
            <button>add</button>
        </div>
    );
}

NewTodoInput.displayName = 'NewTodoInput';

NewTodoInput.propTypes = {
    addTodo: func.isRequired,
    nextTodo: string.isRequired,
    updateTodo: func.isRequired,
};

export default connect(
    [SELECT_NEXT_TODO],
    ([nextTodo], {bindDispatch}) =&gt; ({
        nextTodo,
        addTodo: bindDispatch(ADD_TODO, nextTodo),
        updateTodo: bindDispatch(UPDATE_NEXT_TODO),
    }),
    {
        listeners: {
            [UPDATE_NEXT_TODO]: (value, {setPartialState}) =&gt; {
                setPartialState(SELECT_NEXT_TODO, value);
            },
            [ADD_TODO]: (value, {setPartialState}) =&gt; {
                setPartialState(SELECT_NEXT_TODO, '');