Trouble getting `createEffect` to work outside the browser
Could someone help me get this [1] example from the docs working in node, outside of the brower? I've tried a bunch of stuff, including wrapping it in
createRoot()
[2] without success.
[1] https://docs.solidjs.com/reference/basic-reactivity/create-effect#:~:text=//%20assume%20this%20code,//%20goodbye
2 Replies
node exports are for server usage which doesn't need reactivity so implemented intentionally to be static
you can directly import the browser one or use
--conditions
there's definitely a plan to extract the reactivity core to a separate export
but I think the current focus is on better reactivity runtime solid 2.0, it should probably come around after thatThe current workaround is to use solid-register or something like it.
I left some notes here:
https://dev.to/peerreynders/comment/1pb3g
which made testing reactive logic node-side possible:
https://github.com/peerreynders/solid-bookstore-a/blob/8afd7a94dbef97e8a6c1591a03a58fa27ea9fa04/package.json#L13
https://github.com/peerreynders/solid-bookstore-a/blob/8afd7a94dbef97e8a6c1591a03a58fa27ea9fa04/tests/helpers/index.ts#L19-L61
GitHub
GitHub - atk/solid-register
Contribute to atk/solid-register development by creating an account on GitHub.
DEV Community
Discussion of Testing your Solid.js code with jest
So, you have started to write a nice app or library in Solid.js and TypeScript - good choice, by...
GitHub
solid-bookstore-a/package.json at 8afd7a94dbef97e8a6c1591a03a58fa27...
Segregated UI in Action with SolidJS. Contribute to peerreynders/solid-bookstore-a development by creating an account on GitHub.
GitHub
solid-bookstore-a/tests/helpers/index.ts at 8afd7a94dbef97e8a6c1591...
Segregated UI in Action with SolidJS. Contribute to peerreynders/solid-bookstore-a development by creating an account on GitHub.