{"id":21547278,"url":"https://github.com/the-road-to-learn-react/react-alternative-class-component-syntax","last_synced_at":"2025-08-01T20:12:08.070Z","repository":{"id":70926155,"uuid":"120308008","full_name":"the-road-to-learn-react/react-alternative-class-component-syntax","owner":"the-road-to-learn-react","description":"An alternative/future way of React Class Component with Class Field Declarations","archived":false,"fork":false,"pushed_at":"2020-06-12T08:31:38.000Z","size":736,"stargazers_count":60,"open_issues_count":1,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-21T22:09:33.399Z","etag":null,"topics":["class-properties","es6-classes","javascript-class","react","reactjs"],"latest_commit_sha":null,"homepage":"https://roadtoreact.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/the-road-to-learn-react.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"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,"publiccode":null,"codemeta":null},"funding":{"github":"rwieruch","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2018-02-05T13:25:01.000Z","updated_at":"2025-01-17T16:50:03.000Z","dependencies_parsed_at":"2023-04-10T21:30:39.462Z","dependency_job_id":null,"html_url":"https://github.com/the-road-to-learn-react/react-alternative-class-component-syntax","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/the-road-to-learn-react/react-alternative-class-component-syntax","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-road-to-learn-react%2Freact-alternative-class-component-syntax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-road-to-learn-react%2Freact-alternative-class-component-syntax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-road-to-learn-react%2Freact-alternative-class-component-syntax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-road-to-learn-react%2Freact-alternative-class-component-syntax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/the-road-to-learn-react","download_url":"https://codeload.github.com/the-road-to-learn-react/react-alternative-class-component-syntax/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-road-to-learn-react%2Freact-alternative-class-component-syntax/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268290751,"owners_count":24226646,"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-08-01T02:00:08.611Z","response_time":67,"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":["class-properties","es6-classes","javascript-class","react","reactjs"],"created_at":"2024-11-24T06:14:40.670Z","updated_at":"2025-08-01T20:12:08.049Z","avatar_url":"https://github.com/the-road-to-learn-react.png","language":"JavaScript","funding_links":["https://github.com/sponsors/rwieruch"],"categories":[],"sub_categories":[],"readme":"# react-alternative-class-component-syntax\n\n[![Build Status](https://travis-ci.org/the-road-to-learn-react/react-alternative-class-component-syntax.svg?branch=master)](https://travis-ci.org/the-road-to-learn-react/react-alternative-class-component-syntax) [![Slack](https://slack-the-road-to-learn-react.wieruch.com/badge.svg)](https://slack-the-road-to-learn-react.wieruch.com/) [![Greenkeeper badge](https://badges.greenkeeper.io/the-road-to-learn-react/react-alternative-class-component-syntax.svg)](https://greenkeeper.io/)\n\nReact Class Components can be made much more concise using the *class field declarations*. You can initialize local state without using the constructor and declare class methods by using arrow functions without the extra need to bind them.\n\n```\nclass Counter extends Component {\n  state = { value: 0 };\n\n  handleIncrement = () =\u003e {\n    this.setState(prevState =\u003e ({\n      value: prevState.value + 1\n    }));\n  };\n\n  handleDecrement = () =\u003e {\n    this.setState(prevState =\u003e ({\n      value: prevState.value - 1\n    }));\n  };\n\n  render() {\n    return (\n      \u003cdiv\u003e\n        {this.state.value}\n\n        \u003cbutton onClick={this.handleIncrement}\u003e+\u003c/button\u003e\n        \u003cbutton onClick={this.handleDecrement}\u003e-\u003c/button\u003e\n      \u003c/div\u003e\n    )\n  }\n}\n```\n\n## Installation\n\n* `git clone git@github.com:the-road-to-learn-react/react-alternative-class-component-syntax.git`\n* cd react-alternative-class-component-syntax\n* npm install\n* npm start\n* visit `http://localhost:8080`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthe-road-to-learn-react%2Freact-alternative-class-component-syntax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthe-road-to-learn-react%2Freact-alternative-class-component-syntax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthe-road-to-learn-react%2Freact-alternative-class-component-syntax/lists"}