{"id":16451464,"url":"https://github.com/clumsyme/babel-plugin-react-auto-props","last_synced_at":"2025-03-23T09:30:41.201Z","repository":{"id":35094801,"uuid":"197724437","full_name":"clumsyme/babel-plugin-react-auto-props","owner":"clumsyme","description":"auto add props to your React Component","archived":false,"fork":false,"pushed_at":"2023-01-04T08:48:36.000Z","size":696,"stargazers_count":5,"open_issues_count":13,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-18T19:36:33.652Z","etag":null,"topics":["auto","babel","babel-plugin","props","react"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/babel-plugin-react-auto-props","language":"TypeScript","has_issues":true,"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/clumsyme.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":"2019-07-19T07:29:47.000Z","updated_at":"2022-07-19T10:13:37.000Z","dependencies_parsed_at":"2023-01-15T13:43:41.923Z","dependency_job_id":null,"html_url":"https://github.com/clumsyme/babel-plugin-react-auto-props","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clumsyme%2Fbabel-plugin-react-auto-props","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clumsyme%2Fbabel-plugin-react-auto-props/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clumsyme%2Fbabel-plugin-react-auto-props/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clumsyme%2Fbabel-plugin-react-auto-props/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clumsyme","download_url":"https://codeload.github.com/clumsyme/babel-plugin-react-auto-props/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245081972,"owners_count":20557877,"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":["auto","babel","babel-plugin","props","react"],"created_at":"2024-10-11T10:08:55.061Z","updated_at":"2025-03-23T09:30:40.930Z","avatar_url":"https://github.com/clumsyme.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# babel-plugin-react-auto-props\n\nEnglish | [中文](/README.zh.md)\n\n## What's this?\n\nThis is a babel plugin which auto adds props to your React Component based on your component type.\n\n```jsx\n// what we write\n\u003cdiv\u003e\n    \u003cButton\u003eClick me\u003c/Button\u003e\n    \u003cp\u003eHello world\u003c/p\u003e\n\u003c/div\u003e\n\n// ⚙⚙⚙⚙⚙⚙⚙⚙⚙⚙⚙\n\n// what we get after compile\n\u003cdiv\u003e\n    \u003cButton className=\"my-button\"\u003eClick me\u003c/Button\u003e\n    \u003cp \n        style={\n            color: 'grey',\n            fontSize: 15,\n        }\n    \u003e\n        Hello world\n    \u003c/p\u003e\n\u003c/div\u003e\n```\n\n## How can I use it?\n\nFirstly, install it from npm:\n\n```\nnpm install -D babel-plugin-react-auto-props\n```\n\nSecondly, use it in you babel config:\n\n```js\n// babel.config.js\nconst plugins = [\n    // ...your other babel plugins\n    [\n        'babel-plugin-react-auto-props',\n        {\n            Button: {\n                className: 'my-button',\n            },\n            p: {\n                style: {\n                    color: 'grey',\n                    fontSize: 15,\n                },\n            },\n        },\n    ],\n]\n```\n\nThat's it.\n\n## What's the result of the plugin\n\nGiven the following React element\n\n```jsx\nlet element = (\n    \u003cdiv\u003e\n        \u003cButton\u003eClick me\u003c/Button\u003e\n        \u003cp\u003eHello world\u003c/p\u003e\n    \u003c/div\u003e\n)\n```\n\nWe will get:\n\n```js\nvar element = _react.default.createElement(\n    'div',\n    null,\n    _react.default.createElement(\n        Button,\n        _defineProperty(\n            {\n                className: 'my-button',\n            },\n            'className',\n            'my-button',\n        ),\n        'Click me',\n    ),\n    _react.default.createElement(\n        'p',\n        _defineProperty(\n            {\n                style: {\n                    color: 'grey',\n                    fontSize: 15,\n                },\n            },\n            'style',\n            {\n                color: 'grey',\n                fontSize: 15,\n            },\n        ),\n        'Hello world',\n    ),\n)\n```\n\n## Should I use it?\n\nThis is an experimental project, and auto add props to React Component is anti-pattern. You should consider to use [Specialization](https://reactjs.org/docs/composition-vs-inheritance.html#specialization) in production. However, it's all up to you.\n\n## License\n\nMIT\n\n✨🍰✨\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclumsyme%2Fbabel-plugin-react-auto-props","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclumsyme%2Fbabel-plugin-react-auto-props","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclumsyme%2Fbabel-plugin-react-auto-props/lists"}