{"id":20394657,"url":"https://github.com/justinline/marionette-react-view","last_synced_at":"2026-05-09T08:04:29.364Z","repository":{"id":212188989,"uuid":"730688575","full_name":"justinline/marionette-react-view","owner":"justinline","description":"Render React inside of Marionette views 🎩🐇","archived":false,"fork":false,"pushed_at":"2023-12-13T12:00:51.000Z","size":46,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-05T00:43:36.569Z","etag":null,"topics":["marionette","migration","react","tooling"],"latest_commit_sha":null,"homepage":"","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/justinline.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":"2023-12-12T13:13:50.000Z","updated_at":"2023-12-13T21:22:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"e9f01356-47df-43f1-8d21-d6f7b8d81c33","html_url":"https://github.com/justinline/marionette-react-view","commit_stats":null,"previous_names":["justinline/marionette-react-view"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/justinline/marionette-react-view","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinline%2Fmarionette-react-view","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinline%2Fmarionette-react-view/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinline%2Fmarionette-react-view/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinline%2Fmarionette-react-view/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/justinline","download_url":"https://codeload.github.com/justinline/marionette-react-view/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinline%2Fmarionette-react-view/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32811662,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"online","status_checked_at":"2026-05-09T02:00:06.633Z","response_time":123,"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":["marionette","migration","react","tooling"],"created_at":"2024-11-15T03:53:53.787Z","updated_at":"2026-05-09T08:04:29.336Z","avatar_url":"https://github.com/justinline.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Marionette React View tooling\n\n## Work in progress\nTODO: Publish on `npm`\nTODO: Test more provider use-cases\n\n## What is this?\n\nFound yourself working on an old Marionettejs app? Want to migrate to react so you can have a better DevEx? Can't just rewrite the whole thing?\n\nThis might be for you!\n\nThis small repo provides some utilities for glue-code that can render react components inside of marionette applications.\n\nThis allows you to re-use stuff from your existing React design systems with ease.\n\nNote: It is slightly opinionated in that it uses `zod` for schema validation to get type-safe props.\n\n## Usage\n\n### ReactView \u0026 wrapComponent\n\n`ReactView` is an extended Marionette `View` class with some logic for mapping options to props and such.\nThe API to create a `ReactView` is via the `buildWrapComponent` function.\n\nFirstly you'll want to create and export your own function `wrapComponent` utility where you can pass in any necessary providers.\n\nExample:\n```tsx\n// utils/wrapComponent.ts\nimport { buildWrapComponent } from 'marionette-react-view'\n\ntype CustomOptions = {\n    store: typeof myReduxStore\n};\n\nexport const wrapComponent = buildWrapComponent\u003cCustomOptions\u003e(\n    ({options, children}) =\u003e (\n        \u003cThemeProvider\u003e\n            \u003cProvider store={options.store}\u003e\n                {children}\n            \u003c/Provider\u003e\n        \u003c/ThemeProvider\u003e\n    )\n)\n```\n\nthen you can use this in your existing marionette views, as follows:\n\n```js\nimport { wrapComponent } from '~/utils/wrapComponent';\nimport template from 'lodash/template';\nimport z from 'zod'\n\nconst MyButtonPropsSchema = z.object({text: z.string()});\n\nconst MyButtonView = wrapComponent(\n    (props: z.infer\u003ctypeof MyButtonPropsSchema\u003e) =\u003e \u003cbutton\u003e{props.text}\u003c/button\u003e, \n    { schema: MyButtonPropsSchema } // This is optional runtime type validation\n);\n\nexport default Mn.View.extend({\n    template: template('\u003cdiv class=\"example-react-region\"/\u003e'),\n    regions: {\n        reactRegion: '.example-react-region',\n    },\n    onRender() {\n        this.showChildView(\n            'reactRegion', \n            new MyButtonView(\n                { props: { text: 'Click me!'}, store: myReduxStore }\n            )\n        )\n    }\n})\n```\n\n\n### extendMarionetteViews \u0026 showReactView\n\nThis library also exports a method that can be attached to `Mn.View` called `showReactView`.\nThis replaces `showChildView` with a similar functionality, but the key difference is that it replaces\nthe element of the region the `ReactView` get's rendered into. As a visual example:\n\n```html\n\u003cdiv class=\"el\"\u003e\n  \u003cdiv class=\"template-region\"\u003e\n    \u003cp\u003ereact content\u003c/p\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n```\n\nbecomes\n\n```html\n\u003cdiv class=\"el\"\u003e\n    \u003cp class=\"template-region\"\u003ereact content\u003c/p\u003e\n\u003c/div\u003e\n```\n\nYou can see the middle `\u003cdiv\u003e` in the example got replaced by the `\u003cp\u003e` which is the react component\n\n## Demo\n\nRun `npm run dev` to check out the demo page\n\n## Tests\n\nRun `npm run test` to run the integration tests\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinline%2Fmarionette-react-view","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustinline%2Fmarionette-react-view","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinline%2Fmarionette-react-view/lists"}