How to use the prop-types.shape 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 sharetribe / ftw-daily / src / util / types.js View on Github external
propTypes.bookingUnitType = oneOf([LINE_ITEM_NIGHT, LINE_ITEM_DAY, LINE_ITEM_UNITS]);

const requiredLineItemPropType = (props, propName, componentName) => {
  const prop = props[propName];

  if (!prop || prop === '') {
    return new Error(`Missing line item code prop from ${componentName}.`);
  }
  if (!/^line-item\/.+/.test(prop)) {
    return new Error(`Invalid line item code value ${prop} passed to ${componentName}.`);
  }
};

// Denormalised transaction object
propTypes.transaction = shape({
  id: propTypes.uuid.isRequired,
  type: propTypes.value('transaction').isRequired,
  attributes: shape({
    createdAt: instanceOf(Date),
    lastTransitionedAt: instanceOf(Date).isRequired,
    lastTransition: oneOf(TRANSITIONS).isRequired,

    // An enquiry won't need a total sum nor a booking so these are
    // optional.
    payinTotal: propTypes.money,
    payoutTotal: propTypes.money,

    lineItems: arrayOf(
      shape({
        code: requiredLineItemPropType,
        includeFor: arrayOf(oneOf(['customer', 'provider'])).isRequired,
github hlthi / react-element-based-device-dedector / src / lib / ElementBasedDeviceDedector.js View on Github external
}
        break;
      }
    }
  };

  render() {
    const { devices, ...otherProps } = this.props;
    return ;
  }
}

ElementBasedDeviceDedector.propTypes = {
  onChangeType: PropTypes.func.isRequired,
  devices: PropTypes.arrayOf(
    PropTypes.shape({
      name: PropTypes.string,
      breakpointPx: PropTypes.number,
    }),
  ),
};

ElementBasedDeviceDedector.defaultProps = {
  devices: [
    // below 768px
    {
      name: 'mobile',
      breakpointPx: 768,
    },
    // 768px - 991px
    {
      name: 'tablet',
github jdupont / jdupont.github.io / src / components / archives / blog_list_panel.js View on Github external
);
  }
}

BlogListPanel.defaultProps = {
  chronological: true,
};

BlogListPanel.propTypes = {
  /* eslint-disable react/forbid-prop-types */
  classes: PropTypes.object.isRequired,
  /* eslint-enable react/forbid-prop-types */
  title: PropTypes.string.isRequired,
  posts: PropTypes.arrayOf(PropTypes.shape({
    fileName: PropTypes.string,
    posts: PropTypes.arrayOf(PropTypes.object),
  })).isRequired,
  chronological: PropTypes.bool,
};

export default withStyles(contentStyles, { withTheme: true })(BlogListPanel);
github topcoder-platform / community-app / src / shared / containers / challenge-listing / FilterPanel.jsx View on Github external
loadingUuid: PT.string.isRequired,
    timestamp: PT.number.isRequired,
  }).isRequired,
  filterState: PT.shape().isRequired,
  challenges: PT.arrayOf(PT.shape()),
  selectedCommunityId: PT.string.isRequired,
  getKeywords: PT.func.isRequired,
  getSubtracks: PT.func.isRequired,
  isSavingFilter: PT.bool,
  savedFilters: PT.arrayOf(PT.shape()).isRequired,
  loadingKeywords: PT.bool.isRequired,
  loadingSubtracks: PT.bool.isRequired,
  saveFilter: PT.func.isRequired,
  selectBucket: PT.func.isRequired,
  setFilterState: PT.func.isRequired,
  auth: PT.shape().isRequired,
  tokenV2: PT.string,
};

function mapDispatchToProps(dispatch) {
  const a = actions.challengeListing.filterPanel;
  const cla = challengeListingActions.challengeListing;
  const sa = sidebarActions.challengeListing.sidebar;
  return {
    ...bindActionCreators(a, dispatch),
    getSubtracks: () => {
      dispatch(cla.getChallengeSubtracksInit());
      dispatch(cla.getChallengeSubtracksDone());
    },
    getCommunityList: (auth) => {
      const uuid = shortId();
      dispatch(communityActions.tcCommunity.getListInit(uuid));
github hana-group / hana-ui / src / seeds / DatePicker / DatePicker.js View on Github external
/**
     * @en
     * Custom short names of months.
     *
     * @cn
     * 用户自定义的每个月的名称。
     */
    monthNames: arrayWith12Strings,
    /**
     * @en
     * Custom short names of action buttons.
     *
     * @cn
     * 用户自定义的选择框操作按钮的名称。
     */
    actionNames: PropTypes.shape({
      ok: PropTypes.string,
      cancel: PropTypes.string
    }),
    /**
     * @en
     * The start year.
     *
     * @cn
     * 可选范围的起始年份。
     */
    yearStart: PropTypes.number,
    /**
     * @en
     * The end year.
     *
     * @cn
github neinteractiveliterature / intercode / app / javascript / OrganizationAdmin / NewOrganizationRole.jsx View on Github external
<button type="button"> createOrganizationRole(formState)}
        disabled={mutationInProgress}
      &gt;
        Create role
      </button>
    
  );
}

NewOrganizationRole.propTypes = {
  organizationId: PropTypes.number.isRequired,
  history: PropTypes.shape({
    push: PropTypes.func.isRequired,
  }).isRequired,
};

export default withRouter(NewOrganizationRole);
github Adphorus / react-date-range / src / components / Month.js View on Github external
);
  }
}

Month.defaultProps = {};

Month.propTypes = {
  style: PropTypes.object,
  styles: PropTypes.object,
  month: PropTypes.object,
  drag: PropTypes.object,
  dateOptions: PropTypes.object,
  disabledDates: PropTypes.array,
  preview: PropTypes.shape({
    startDate: PropTypes.object,
    endDate: PropTypes.object,
  }),
  showPreview: PropTypes.bool,
  displayMode: PropTypes.oneOf(['dateRange', 'date']),
  minDate: PropTypes.object,
  maxDate: PropTypes.object,
  ranges: PropTypes.arrayOf(rangeShape),
  focusedRange: PropTypes.arrayOf(PropTypes.number),
  onDragSelectionStart: PropTypes.func,
  onDragSelectionEnd: PropTypes.func,
  onDragSelectionMove: PropTypes.func,
  onMouseLeave: PropTypes.func,
  monthDisplayFormat: PropTypes.string,
  showWeekDays: PropTypes.bool,
  showMonthName: PropTypes.bool,
github MorpheoOrg / morpheo-analytics / src / frontend / js / business / models / experiment / components / detail / index.js View on Github external
isVisible={algo.modal.create}
                    onConfirm={this.onConfirm}
                    onCancel={this.onCancel}
                /&gt;
                
                
            
        ) : null;
    }
}

Detail.propTypes = {
    query: PropTypes.shape({
        update: PropTypes.string,
    }),
    item: PropTypes.shape({}),
    loading: PropTypes.shape({}).isRequired,
};

Detail.defaultProps = {
    item: null,
    query: null,
};

function mapStateToProps(s, ownProps) {
    const state = s.models.experiment;

    const id = ownProps.match.params.id || state.item.id,
        item = id ? state.item.results[id] : null;

    return {
        user: s.user,
github erikthedeveloper / react-calendar-components / src / components / State.js View on Github external
...merged.initialState,
      ...props.initialState,
    },
    stateSetters: setState =&gt; ({
      ...merged.stateSetters(setState),
      ...props.stateSetters(setState),
    }),
  }));

const StoryState = ({stateProps, children}) =&gt; (
  
);

StoryState.propTypes = {
  stateProps: PropTypes.arrayOf(
    PropTypes.shape({
      initialState: State.propTypes.initialState,
      stateSetters: State.propTypes.stateSetters,
    })
  ),
};

export default State;
export {StoryState};
github ayr-ton / kamu / assets / src / components / libraries / Library.jsx View on Github external
hasMore={this.state.hasNextPage}
          threshold={950}
          loader={}
        &gt;
          
        
      
    );
  }
}

Library.propTypes = {
  slug: PropTypes.string.isRequired,
  history: PropTypes.shape({
    replace: PropTypes.func.isRequired,
    location: PropTypes.shape({
      search: PropTypes.string,
    }).isRequired,
  }).isRequired,
};

export default Library;