{"id":16528347,"url":"https://github.com/danvk/reactjs-prop-validation","last_synced_at":"2025-07-30T12:04:49.551Z","repository":{"id":20916484,"uuid":"24204362","full_name":"danvk/reactjs-prop-validation","owner":"danvk","description":"A ReactJS Mixin which enforces that a Component document all its props in propTypes.","archived":false,"fork":false,"pushed_at":"2014-09-18T23:42:45.000Z","size":152,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-09T09:13:01.741Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danvk.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":"2014-09-18T20:42:45.000Z","updated_at":"2015-03-25T18:55:28.000Z","dependencies_parsed_at":"2022-08-29T10:20:22.326Z","dependency_job_id":null,"html_url":"https://github.com/danvk/reactjs-prop-validation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/danvk/reactjs-prop-validation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danvk%2Freactjs-prop-validation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danvk%2Freactjs-prop-validation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danvk%2Freactjs-prop-validation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danvk%2Freactjs-prop-validation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danvk","download_url":"https://codeload.github.com/danvk/reactjs-prop-validation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danvk%2Freactjs-prop-validation/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267865793,"owners_count":24157343,"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","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-10-11T17:39:47.648Z","updated_at":"2025-07-30T12:04:49.503Z","avatar_url":"https://github.com/danvk.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"reactjs-prop-validation\n=======================\n\nA ReactJS Mixin which enforces that a Component document all its props in propTypes.\n\nUsage\n-----\n\n```html\n\n\u003cscript src=\"prop-validation-mixin.js\"\u003e\u003c/script\u003e\n\n\u003cdiv id=\"content\"\u003e\u003c/div\u003e\n\n\u003cscript type=\"text/jsx\"\u003e\n/** @React.DOM */\n\nvar Root = React.createComponent({\n  propTypes: {\n    name: React.PropTypes.string.isRequired\n  },\n  mixins: [PropValidationMixin],\n  render: function() {\n    return \u003cdiv\u003e{this.props.name}\u003c/div\u003e;\n  }\n});\n\nReact.renderComponent(\u003cRoot name=\"Bob\" /\u003e, document.getElementById('content'));\n\u003c/script\u003e\n```\n\nThis enforces a requirement that every `prop` that the `Root` component\naccesses appears in `propTypes` (at least in dev mode on browsers which support\nit, see below).\n\n\nWhy would you want this?\n------------------------\n\nIt's good practice to document the API of your components. The `propTypes`\nfield lets you do this in a way that's enforced at runtime and hence unlikely\nto drift vs. the implementation.\n\nThe built-in `propTypes` system is more of a property validation system than a\ncomplete API spec. There's nothing that forces you to enumerate all your\ncomponent's `props` in the `propTypes` section. This Mixin changes that.\n\nIf you want to use a component and you see `mixins: [PropValidationMixin]`,\nthen you can be confident that its `propTypes` section specifies its complete API.\n\nHow does it work?\n-----------------\n\nWhen you mix in `PropValidationMixin`, it wraps an ES6 Proxy around\n`this.props` which intercepts all reads from `this.props`. When you read\n`this.props.foo`, it checks that `foo` appears in `this.propTypes`. This\nensures that the component can't ever use a property that it doesn't specify.\n\nNote that this requires the ES6 Proxy, which is currently only supported in\nFirefox.\n\nJust like `propTypes`, `PropValidationMixin` is a no-op when you use the\nproduction version of ReactJS (i.e. the minified version).  It won't affect the\nperformance or behavior of your site.\n\nDevelopment\n-----------\n\nTo get going, run:\n\n```bash\nnpm install\n```\n\nThen open test/dev.html in Firefox.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanvk%2Freactjs-prop-validation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanvk%2Freactjs-prop-validation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanvk%2Freactjs-prop-validation/lists"}