|
| 1 | +# DOMiNATIVE-Solid |
| 2 | + |
| 3 | +### **Custom render and patches for SolidJS to work with [DOMiNATIVE](https://github.com/SudoMaker/DOMiNATIVE) on [NativeScript](https://nativescript.org/)** |
| 4 | + |
| 5 | +[Playground](https://stackblitz.com/edit/nativescript-dominative-solid?file=app/app.jsx) |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Installation |
| 10 | + |
| 11 | +Via npm: |
| 12 | + |
| 13 | +```shell |
| 14 | +npm install dominative-solid dominative @utls/undom-ef solid-js |
| 15 | +``` |
| 16 | + |
| 17 | +**Note:** `dominative`, `@utls/undom-ef`, `solid-js` are peer dependencies, you have to install them manually. |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Usage |
| 22 | + |
| 23 | +```jsx |
| 24 | +import { Application } from "@nativescript/core" |
| 25 | +import { render } from "dominative-solid" |
| 26 | +import { createSignal } from "solid-js" |
| 27 | + |
| 28 | +const App = () => { |
| 29 | + const [count, setCount] = createSignal(0) |
| 30 | + const increment = () => { |
| 31 | + setCount(c => c + 1) |
| 32 | + } |
| 33 | + return <> |
| 34 | + <actionbar title="Hello, SolidJS!"></actionbar> |
| 35 | + <stacklayout> |
| 36 | + <label>You have taapped {count()} time(s)</label> |
| 37 | + <button class="-primary" on:tap={increment}>Tap me!</button> |
| 38 | + </stacklayout> |
| 39 | + </> |
| 40 | +} |
| 41 | + |
| 42 | +const create = () => { |
| 43 | + render(App, document.documentElement) |
| 44 | + return document |
| 45 | +} |
| 46 | + |
| 47 | +Application.run({ create }) |
| 48 | + |
| 49 | +``` |
| 50 | + |
| 51 | +--- |
| 52 | + |
| 53 | +## Caveats |
| 54 | + |
| 55 | +You have to patch the `exports` key in the `package.json` form `node_modules/solid-js`. It is recommended to use [patch-package](https://www.npmjs.com/package/patch-package) for patching. |
| 56 | + |
| 57 | +For example: |
| 58 | + |
| 59 | +```patch |
| 60 | +diff --git a/node_modules/solid-js/package.json b/node_modules/solid-js/package.json |
| 61 | +index b4c3656..47e362f 100644 |
| 62 | +--- a/node_modules/solid-js/package.json |
| 63 | ++++ b/node_modules/solid-js/package.json |
| 64 | +@@ -44,48 +44,6 @@ |
| 65 | + ], |
| 66 | + "exports": { |
| 67 | + ".": { |
| 68 | +- "browser": { |
| 69 | +- "development": { |
| 70 | +- "import": { |
| 71 | +- "types": "./types/index.d.ts", |
| 72 | +- "default": "./dist/dev.js" |
| 73 | +- }, |
| 74 | +- "require": "./dist/dev.cjs" |
| 75 | +- }, |
| 76 | +- "import": { |
| 77 | +- "types": "./types/index.d.ts", |
| 78 | +- "default": "./dist/solid.js" |
| 79 | +- }, |
| 80 | +- "require": "./dist/solid.cjs" |
| 81 | +- }, |
| 82 | +- "deno": { |
| 83 | +- "import": { |
| 84 | +- "types": "./types/index.d.ts", |
| 85 | +- "default": "./dist/server.js" |
| 86 | +- }, |
| 87 | +- "require": "./dist/server.cjs" |
| 88 | +- }, |
| 89 | +- "worker": { |
| 90 | +- "import": { |
| 91 | +- "types": "./types/index.d.ts", |
| 92 | +- "default": "./dist/server.js" |
| 93 | +- }, |
| 94 | +- "require": "./dist/server.cjs" |
| 95 | +- }, |
| 96 | +- "node": { |
| 97 | +- "import": { |
| 98 | +- "types": "./types/index.d.ts", |
| 99 | +- "default": "./dist/server.js" |
| 100 | +- }, |
| 101 | +- "require": "./dist/server.cjs" |
| 102 | +- }, |
| 103 | +- "development": { |
| 104 | +- "import": { |
| 105 | +- "types": "./types/index.d.ts", |
| 106 | +- "default": "./dist/dev.js" |
| 107 | +- }, |
| 108 | +- "require": "./dist/dev.cjs" |
| 109 | +- }, |
| 110 | + "import": { |
| 111 | + "types": "./types/index.d.ts", |
| 112 | + "default": "./dist/solid.js" |
| 113 | +``` |
| 114 | + |
| 115 | +## License |
| 116 | + |
| 117 | +MIT |
0 commit comments