{"id":15366392,"url":"https://github.com/jasonboy/react-china-location","last_synced_at":"2026-04-02T01:22:11.675Z","repository":{"id":20799429,"uuid":"90852998","full_name":"JasonBoy/react-china-location","owner":"JasonBoy","description":"React Component for china-location","archived":false,"fork":false,"pushed_at":"2022-12-06T21:30:24.000Z","size":1233,"stargazers_count":14,"open_issues_count":15,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-23T09:51:19.314Z","etag":null,"topics":["china","china-city","china-location","component","react"],"latest_commit_sha":null,"homepage":null,"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/JasonBoy.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-05-10T10:40:18.000Z","updated_at":"2024-12-24T10:57:37.000Z","dependencies_parsed_at":"2023-01-12T03:30:56.819Z","dependency_job_id":null,"html_url":"https://github.com/JasonBoy/react-china-location","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JasonBoy%2Freact-china-location","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JasonBoy%2Freact-china-location/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JasonBoy%2Freact-china-location/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JasonBoy%2Freact-china-location/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JasonBoy","download_url":"https://codeload.github.com/JasonBoy/react-china-location/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241018426,"owners_count":19895075,"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":["china","china-city","china-location","component","react"],"created_at":"2024-10-01T13:18:39.826Z","updated_at":"2026-04-02T01:22:11.628Z","avatar_url":"https://github.com/JasonBoy.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-china-location [![npm](https://img.shields.io/npm/v/react-china-location.svg)](https://www.npmjs.com/package/react-china-location)\nReact Component for [china-location](https://github.com/JasonBoy/china-location)\n\nIt uses the simple html select/option tag,\nto use custom UI, install the `china-location` only and make your own UI component.\n\n![demo](https://raw.githubusercontent.com/JasonBoy/react-china-location/master/demo/demo.png)\n\n## Usage\n\n`npm install china-location react-china-location --save` or  \n`yarn add china-location react-china-location`\n\n```javascript\nimport locationData from 'china-location/dist/location.json';\nimport ChinaLocation from 'react-china-location';\n\nclass App extends React.Component {\n  constructor (props) {\n    super(props);\n\n    this.onLocationChange = this.onLocationChange.bind(this);\n\n    this.state = {\n      currentLocation: {},\n    }\n  }\n\n\n  onLocationChange (newLocation) {\n    //{\n    //  province: {code: '110000', name: '北京市'},\n    //  city: {code: '110000', name: '北京市'},\n    //  district: {code: '110101', name: '东城区'}\n    //}\n    console.log(newLocation);\n    this.setState({\n      currentLocation: newLocation,\n    });\n  }\n\n  render () {\n    return (\n      \u003cChinaLocation className=\"custom-china-location\" \n                     list={locationData} \n                     onLocationChange={this.onLocationChange}\n      /\u003e\n    )\n  }\n}\n```\n\n### Props\n\n- `className\u003cstring\u003e`: pass custom css class to the component root element\n- `list\u003cobject\u003e`: location data from `china-location`\n- `onLocationChange\u003cfunction\u003e`: be notified when user select different option\n\n## Demo\n\nGo to `demo/build` and open `index.html` in your browser.\n\n## LICENSE\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasonboy%2Freact-china-location","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjasonboy%2Freact-china-location","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasonboy%2Freact-china-location/lists"}