{"id":17767434,"url":"https://github.com/jamiebuilds/react-required-if","last_synced_at":"2025-07-26T12:04:55.554Z","repository":{"id":48889755,"uuid":"55569932","full_name":"jamiebuilds/react-required-if","owner":"jamiebuilds","description":"React PropType to conditionally add `.isRequired` based on other props","archived":false,"fork":false,"pushed_at":"2021-07-01T08:29:09.000Z","size":4,"stargazers_count":73,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-12T21:02:50.731Z","etag":null,"topics":["prop-types","props","react","validation"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jamiebuilds.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-06T02:27:55.000Z","updated_at":"2024-10-20T16:06:54.000Z","dependencies_parsed_at":"2022-09-13T17:02:47.393Z","dependency_job_id":null,"html_url":"https://github.com/jamiebuilds/react-required-if","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamiebuilds%2Freact-required-if","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamiebuilds%2Freact-required-if/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamiebuilds%2Freact-required-if/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamiebuilds%2Freact-required-if/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jamiebuilds","download_url":"https://codeload.github.com/jamiebuilds/react-required-if/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243742480,"owners_count":20340658,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["prop-types","props","react","validation"],"created_at":"2024-10-26T20:46:46.465Z","updated_at":"2025-03-15T14:30:22.450Z","avatar_url":"https://github.com/jamiebuilds.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-required-if\n\n\u003e React PropType to conditionally add `.isRequired` based on other props\n\n## Install\n\n```sh\n$ npm install --save react-required-if\n```\n\n## Usage\n\n```js\nimport React, {PropTypes} from 'react';\nimport requiredIf from 'react-required-if';\n\nexport default class Component extends React.Component {\n  static propTypes = {\n    disabled: PropTypes.bool,\n    onClick: requiredIf(PropTypes.func, props =\u003e !props.disabled)\n  };\n\n  render() {\n    return \u003cbutton onClick={this.props.onClick}\u003eClick Me\u003c/button\u003e\n  }\n}\n```\n\n**Result:**\n\n```js\nimport React from 'react';\nimport {render} from 'react-dom';\nimport Component from './Component';\n\nrender(\n  \u003cdiv\u003e\n    \u003cComponent onClick={() =\u003e {})/\u003e // ok\n    \u003cComponent disabled={true}/\u003e // ok\n    \u003cComponent/\u003e // NOooooooo\n  \u003c/div\u003e,\n  document.getElementById('root')\n);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamiebuilds%2Freact-required-if","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjamiebuilds%2Freact-required-if","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamiebuilds%2Freact-required-if/lists"}