{"id":19114454,"url":"https://github.com/pinebit/react-cr","last_synced_at":"2025-04-30T22:50:15.154Z","repository":{"id":65482957,"uuid":"101998918","full_name":"pinebit/react-cr","owner":"pinebit","description":"A tiny library for conditional rendering in JSX.","archived":false,"fork":false,"pushed_at":"2017-09-03T14:13:02.000Z","size":2434,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T10:15:58.148Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pinebit.github.io/react-cr","language":"JavaScript","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/pinebit.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":"2017-08-31T12:34:51.000Z","updated_at":"2018-04-16T01:00:21.000Z","dependencies_parsed_at":"2023-01-25T11:15:17.951Z","dependency_job_id":null,"html_url":"https://github.com/pinebit/react-cr","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinebit%2Freact-cr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinebit%2Freact-cr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinebit%2Freact-cr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinebit%2Freact-cr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pinebit","download_url":"https://codeload.github.com/pinebit/react-cr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251795387,"owners_count":21645019,"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-11-09T04:42:18.967Z","updated_at":"2025-04-30T22:50:15.125Z","avatar_url":"https://github.com/pinebit.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-cr\n\nA tiny library for conditional rendering in JSX.\n\nThe purpose of this library to offer a few components that will replace your JS-in-JSX with behavioral components.\n\nFor example, instead of writing conditions like this:\n```jsx harmony\n{this.state.isLoading \u0026\u0026 \u003cLoading /\u003e}\n```\n\nYou can use one of react-cr components:\n```jsx harmony\n\u003cVisibility visible={this.state.isLoading}\u003e\n  \u003cLoading /\u003e\n\u003c/Visibility\u003e\n```\n\nSimilar to this example, the library offers: `Switch, Mobile, Desktop, Repeat, Interleave`.\nCheck [the complete spec here](https://pinebit.github.io/react-cr).\n\n## Basic Usage\n\n`npm install --save react-cr`\n\n```jsx harmony\nimport { Visibility, Switch, Mobile, Desktop, Repeat, Interleave } from 'react-cr';\n\n// control children visibility\n\u003cVisibility visible={this.state.showLogo}\u003e\n  \u003cLogo /\u003e\n\u003c/Visibility\u003e\n\n// select child by index\n\u003cSwitch index={1}\u003e\n  \u003cFirst /\u003e\n  \u003cSecond /\u003e\n\u003c/Switch\u003e\n\n// select child by multiple indices\n\u003cSwitch index={[1, 10, 12, 43]}\u003e\n  {items.map(...)}\n\u003c/Switch\u003e\n\n// repeat (clone) given n times \n\u003cRepeat count={this.state.stars}\u003e\n  \u003cRatingStar /\u003e\n\u003c/Repeat\u003e\n\n// render for mobile (or Desktop) only\n\u003cMobile\u003e\n  \u003cMobileMenu /\u003e\n\u003c/Mobile\u003e\n\n// interleaves children with the given separator\n\u003cInterleave wrapper=\"p\" separator={\u003cspan\u003e,\u003c/span\u003e}\u003e\n  \u003cspan key=\"alpha\"\u003eAlpha\u003c/span\u003e\n  \u003cspan key=\"beta\"\u003eBeta\u003c/span\u003e\n  \u003cspan key=\"gamma\"\u003eGamma\u003c/span\u003e\n\u003c/Interleave\u003e\n\n```\n\n## Components\n\n[See detailed specification](https://pinebit.github.io/react-cr/#/components)\n\n## License\n\n*react-cr* is available under MIT. See LICENSE for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinebit%2Freact-cr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpinebit%2Freact-cr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinebit%2Freact-cr/lists"}