{"id":22774287,"url":"https://github.com/tvrcgo/mobx-react-connect","last_synced_at":"2025-04-15T09:43:53.983Z","repository":{"id":57299681,"uuid":"79090599","full_name":"tvrcgo/mobx-react-connect","owner":"tvrcgo","description":"Connect react component, mobx store and css modules.","archived":false,"fork":false,"pushed_at":"2017-04-17T09:25:15.000Z","size":21,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T18:54:10.355Z","etag":null,"topics":["css-modules","mobx","mobx-react","react"],"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/tvrcgo.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-01-16T06:45:33.000Z","updated_at":"2021-01-26T23:47:49.000Z","dependencies_parsed_at":"2022-08-26T21:50:46.593Z","dependency_job_id":null,"html_url":"https://github.com/tvrcgo/mobx-react-connect","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/tvrcgo%2Fmobx-react-connect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tvrcgo%2Fmobx-react-connect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tvrcgo%2Fmobx-react-connect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tvrcgo%2Fmobx-react-connect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tvrcgo","download_url":"https://codeload.github.com/tvrcgo/mobx-react-connect/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248565083,"owners_count":21125418,"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":["css-modules","mobx","mobx-react","react"],"created_at":"2024-12-11T18:13:38.366Z","updated_at":"2025-04-15T09:43:53.962Z","avatar_url":"https://github.com/tvrcgo.png","language":"JavaScript","readme":"# mobx-react-connect\n\nConnect react component, mobx store and css module.\n\n**connect( StatelessComponent, Stores, CSSModule )**\n\n### Features\n- Only stateless component.\n- Map observable stores to component.\n- Easy to use css modules.\n\n### Install\n```js\nnpm install mobx-react-connect --save-dev\n```\n\n## Example\n\n### Connect component and store.\n\nStore class\n\n```js\n// index.store.js\nexport default class Store {\n  @observable id = 0\n  constructor (props) {\n    const { id } = props\n    this.id = id\n  }\n\n  @computed\n  get userId () {\n    return this.id\n  }\n\n  @action.bound\n  increase() {\n    this.id++\n  }\n}\n```\n\nReact component.\n\n```js\n// index.js\nimport { connect } from 'mobx-react-connect'\nimport Store from './index.store'\n\n// functional component\nconst HelloView = (props, { store }) =\u003e {\n  return (\n    \u003ch1\u003ehello buddy. { store.userId } \u003ca onClick={store.increase}\u003enext\u003c/a\u003e\u003c/h1\u003e\n  )\n}\n\nexport default connect(HelloView, {\n  store: Store\n})\n```\n\nInstantiate component.\n\n```js\nimport HelloView from './index'\n\n\u003cHelloView id={2} /\u003e\n```\n\n### Connect component and CSS Modules\n\nYou won't need to set className for element like `className={css.title}` any more.\n\n- Set `clazz` attribute for element. Styles in css module will be combined into `className`.\n- Multiple style names is available, like `clazz='wrap title'`.\n- `clazz` and `className` can be concurrent and styles will be joined together.\n\n```js\nimport { connect } from 'mobx-react-connect'\nimport css from './index.css'\n\nconst View = () =\u003e {\n  return (\n    \u003cdiv clazz='green red'\u003e\u003c/div\u003e\n  )\n}\n\nexport default connect(View, {}, css)\n```\n\n`index.css` - Styles for component\n\n```css\n.green {\n  background-color: green;\n}\n\n.red {\n  color: red;\n}\n```\n\n## License\nMIT","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftvrcgo%2Fmobx-react-connect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftvrcgo%2Fmobx-react-connect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftvrcgo%2Fmobx-react-connect/lists"}