{"id":13739784,"url":"https://github.com/evolify/babel-plugin-react-directive","last_synced_at":"2026-01-12T02:43:04.434Z","repository":{"id":97954134,"uuid":"146563996","full_name":"evolify/babel-plugin-react-directive","owner":"evolify","description":"Use directive in React.","archived":false,"fork":false,"pushed_at":"2023-09-06T01:54:05.000Z","size":23,"stargazers_count":28,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-31T21:06:29.712Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/evolify.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-08-29T07:44:13.000Z","updated_at":"2024-06-10T02:17:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"0bca901a-f001-4d7e-98e0-b4bca7971009","html_url":"https://github.com/evolify/babel-plugin-react-directive","commit_stats":{"total_commits":6,"total_committers":2,"mean_commits":3.0,"dds":"0.16666666666666663","last_synced_commit":"37028ecd0283a8d665c2555afa4cd9f4b839a093"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolify%2Fbabel-plugin-react-directive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolify%2Fbabel-plugin-react-directive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolify%2Fbabel-plugin-react-directive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolify%2Fbabel-plugin-react-directive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evolify","download_url":"https://codeload.github.com/evolify/babel-plugin-react-directive/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224758216,"owners_count":17364970,"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":[],"created_at":"2024-08-03T04:00:37.601Z","updated_at":"2026-01-12T02:43:04.381Z","avatar_url":"https://github.com/evolify.png","language":"TypeScript","funding_links":[],"categories":["Plugins"],"sub_categories":["React"],"readme":"# babel-plugin-react-directive\nUse directive in React.\n\nNow you can use `r-if`、`r-for` in jsx.\n\n## Usage:\n\n1. Install: `yarn add babel-plugin-react-directive --dev`\n\n2. Add to your .babelrc:\n\n   ```\n   {\n       plugins:[\n           'react-directive'\n       ]\n   }\n   ```\n\n   \n\n### r-if:\n\n* Before:\n\n  ```jsx\n  render(){\n      const visible = true\n      return(\n          \u003cdiv\u003e\n              {\n                  visible ? \u003cdiv\u003econtent\u003cdiv\u003e\n                          : ''\n              }\n          \u003c/div\u003e\n      )\n  }\n  ```\n\n  \n\n* Now:\n\n  ```jsx\n  render(){\n      const visible = true\n      return(\n          \u003cdiv\u003e\n              \u003cdiv r-if = {visible}\u003econtent\u003c/div\u003e\n          \u003c/div\u003e\n      )\n  }\n  ```\n\n\n\n### r-for:\n\n* Before:\n\n  ```jsx\n  render(){\n      const list = [1, 2, 3, 4, 5]\n      return(\n          \u003cdiv\u003e\n              {\n                  list.map((item,index)=\u003e(\n                  \t\u003cdiv key={index}\u003e{item}\u003c/div\u003e\n                  ))\n              }\n          \u003c/div\u003e\n      )\n  }\n  ```\n\n  \n\n* Now:\n\n  ```jsx\n  render(){\n      const list = [1, 2, 3, 4, 5]\n      return(\n          \u003cdiv\u003e\n              {/* auto set 'key' to the index */} \n              \u003cdiv r-for = {item in list}\u003e{item}\u003c/div\u003e\n              {/* or you can set the key manually */}\n              \u003cdiv r-for = {(item,index) in list} key = {index+1}\u003e{item}\u003c/div\u003e\n          \u003c/div\u003e\n      )\n  }\n  ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevolify%2Fbabel-plugin-react-directive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevolify%2Fbabel-plugin-react-directive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevolify%2Fbabel-plugin-react-directive/lists"}