I am confused. I’m seeing lots of “porting guides” and talks about someone using Purescript + React somewhere, so it’d seem like… well… it’s used. But I found exactly 0 (zero) working “Hello World”-level tutorials. Furthest I saw so far was a code that just compiles. Doesn’t work in a browser though, it’s just buildable.
For your enjoyment I made a quick showdown of all “Hello World” React PureScript tutorials I managed to get a hang of, further below.
With that said, my question is simple: can please somebody provide a simple react-hooks
(as I presume “react-classic” is nowadays ain’t that interesting) code that when I do:
spago bundle-app
-
firefox ./index.html
(whereindex.html
is obviously pre-bundled by me and just refers toindex.js
that got created by1
)
I get a “Hello World” label in my browser?
Here’s showdown of all “Hello World” tutorials I managed to find. Besides tutorial-specific problems, I also found that in general “blog-post tutorials” overcomplicate everything. They try to introduce a web-server (which not only unnecessary but also goes south as you’ll further see), and frequently also npm-related components and js even though you already have spago
with react, and everything else would seem unnecessary.
-
Official react-basic page: it’s messy. If you go through everything, you’ll find in different locations 3 non-404ed references:
- Examples in
purescript-cookbook
. I tried ButtonReactHooks one, which sounds simple enough. Well… it builds, that all I can say. If you usespago bundle-app
to createindex.js
you getCould not resolve "./output/Main/index.js"
. I found a pre-bundledindex.js
file, apparently I wasn’t the first to stumble upon the error… And it goes along with pre-bundledindex.html
, but opening it just shows empty page -
purescript-react-realworld
: that’s obviously not a “Hello World”. -
Examples in
react-basic
v14.0.0 branch. I triedcounter
which sounds simple, but it fails to even compile withUnable to parse module: Unexpected token 'RowList'
.
- Examples in
-
Getting started with a PureScript React project | by Zelenya: the tutorial flow is random, it introduces
npm start
before introducingstyles.css
in a separate chapter, sonpm start
produces errors; and later it introduces PureScript code before installingreact-player
in a separate chapter, so again you get errors.But even if done correctly, all I can say is that the code builds. Running
parcel serve …
vianpm start
results inmalloc(): invalid size (unsorted)
, and pointing a browser directly topublic/index.html
just shows an empty page. -
The no-nonsense PureScript and React HelloWorld tutorial: first problem is
npm install --save-dev craco-purescript-loader
gives errorunable to resolve dependency tree
. Solved with--legacy-peer-deps
. Barring that, with everything in placenpm run start
gives compilation errorWebpack has been initialized using a configuration object that does not match the API schema
.