{"id":20772150,"url":"https://github.com/davinci2015/react-ternary","last_synced_at":"2026-05-06T19:36:15.780Z","repository":{"id":57346245,"uuid":"123790456","full_name":"davinci2015/react-ternary","owner":"davinci2015","description":"Ternary operator in a declarative way","archived":false,"fork":false,"pushed_at":"2018-03-05T11:57:18.000Z","size":104,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-10T09:04:16.171Z","etag":null,"topics":["conditional-statements","react","ternary"],"latest_commit_sha":null,"homepage":"","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/davinci2015.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":"2018-03-04T13:20:12.000Z","updated_at":"2018-03-05T12:06:13.000Z","dependencies_parsed_at":"2022-09-18T10:22:03.101Z","dependency_job_id":null,"html_url":"https://github.com/davinci2015/react-ternary","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davinci2015%2Freact-ternary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davinci2015%2Freact-ternary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davinci2015%2Freact-ternary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davinci2015%2Freact-ternary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davinci2015","download_url":"https://codeload.github.com/davinci2015/react-ternary/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234477306,"owners_count":18839644,"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":["conditional-statements","react","ternary"],"created_at":"2024-11-17T12:19:27.710Z","updated_at":"2026-05-06T19:36:15.751Z","avatar_url":"https://github.com/davinci2015.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-ternary\r\n\r\nUse ternary conditional operator in a declarative way.\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install react-ternary --save\r\n```\r\n\r\n## Usage\r\n\r\nInstead of:\r\n```js\r\nimport React, { Component } from 'react'\r\n\r\nclass App extends Component {\r\n  render() {\r\n    return(\r\n      \u003cdiv\u003e\r\n        {\r\n          this.props.language === 'JS' ? \r\n            \u003cdiv\u003eLanguage is JS\u003c/div\u003e : \r\n            \u003cdiv\u003eLanguage is not JS\u003c/div\u003e\r\n        }\r\n      \u003c/div\u003e\r\n    )\r\n  }\r\n}\r\n```\r\n\r\nyou can use ternary in a declarative way:\r\n```js\r\nimport React, { Component } from 'react'\r\nimport Ternary from 'react-ternary'\r\n\r\nclass App extends Component {\r\n  render() {\r\n    return(\r\n      \u003cTernary condition={this.props.language === 'JS'}\u003e\r\n        \u003cdiv\u003eLanguage is JS\u003c/div\u003e     {/* first element will render if condition is true */}\r\n        \u003cdiv\u003eLanguage is not JS\u003c/div\u003e {/* second element will render if condition is false */ }\r\n      \u003c/Ternary\u003e\r\n    )\r\n  }\r\n}\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavinci2015%2Freact-ternary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavinci2015%2Freact-ternary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavinci2015%2Freact-ternary/lists"}