{"id":21413190,"url":"https://github.com/github0013/react-beautiful-dnd-mobx","last_synced_at":"2025-07-16T12:39:25.852Z","repository":{"id":141757164,"uuid":"123222980","full_name":"github0013/react-beautiful-dnd-mobx","owner":"github0013","description":null,"archived":false,"fork":false,"pushed_at":"2018-02-28T03:48:46.000Z","size":6,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-10T15:49:21.878Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/github0013.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2018-02-28T03:20:32.000Z","updated_at":"2021-09-22T20:33:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"7e60fc9f-0315-4f28-ab47-efb9b491e1a6","html_url":"https://github.com/github0013/react-beautiful-dnd-mobx","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/github0013/react-beautiful-dnd-mobx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github0013%2Freact-beautiful-dnd-mobx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github0013%2Freact-beautiful-dnd-mobx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github0013%2Freact-beautiful-dnd-mobx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github0013%2Freact-beautiful-dnd-mobx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/github0013","download_url":"https://codeload.github.com/github0013/react-beautiful-dnd-mobx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github0013%2Freact-beautiful-dnd-mobx/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265509713,"owners_count":23779419,"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-22T18:17:27.393Z","updated_at":"2025-07-16T12:39:25.787Z","avatar_url":"https://github.com/github0013.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-beautiful-dnd-mobx\n\nWhen to use mobx + react-beautiful-dnd, it doesn't work as expected if you just copy their sample.\n\n## their sample\n\n```jsx\n  render() {\n    return (\n      \u003cDragDropContext onDragEnd={this.onDragEnd}\u003e\n        \u003cDroppable droppableId=\"droppable\" direction=\"horizontal\"\u003e\n          {(provided, snapshot) =\u003e (\n            \u003cdiv\n              ref={provided.innerRef}\n              style={getListStyle(snapshot.isDraggingOver)}\n              {...provided.droppableProps}\n            \u003e\n              {this.state.items.map((item, index) =\u003e (\n                \u003cDraggable key={item.id} draggableId={item.id} index={index}\u003e\n\n```\n\n## you would chage like this for mobx (this won't work properly) \n\n```jsx\n\n  @mobx.observable items = [{id: \"...\", content: \"...\"}]\n\n...\n...\n\n\n  render() {\n    return (\n      \u003cDragDropContext onDragEnd={this.onDragEnd}\u003e\n        \u003cDroppable droppableId=\"droppable\" direction=\"horizontal\"\u003e\n          {(provided, snapshot) =\u003e (\n            \u003cdiv\n              ref={provided.innerRef}\n              style={getListStyle(snapshot.isDraggingOver)}\n              {...provided.droppableProps}\n            \u003e\n              {\n                // mobx observable object here\n              }\n              {this.items.map((item, index) =\u003e (\n                \u003cDraggable key={item.id} draggableId={item.id} index={index}\u003e\n\n```\n\nThe problem here is `this.items` (mobx observable object) is in a function call `(provided, snapshot) =\u003e ()`.  When this function is called, `this.items` is not being observed, so that it breaks the react cycles.\n\n\n## solution\nhttps://github.com/atlassian/react-beautiful-dnd/issues/156  \n\nExtract the function call content into a class, and add `@observer` to it.  \nhttps://github.com/github0013/react-beautiful-dnd-mobx/blob/master/src/DraggableInternal.tsx#L7  \nThen call the component with props. * `items={this.items.dropPointA}` is mobx observable object  \nhttps://github.com/github0013/react-beautiful-dnd-mobx/blob/master/src/App.tsx#L49  \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithub0013%2Freact-beautiful-dnd-mobx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgithub0013%2Freact-beautiful-dnd-mobx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithub0013%2Freact-beautiful-dnd-mobx/lists"}