liqula / react-hs

A GHCJS binding to React based on the Flux design. The flux design pushes state and complicated logic out of the view, allowing the rendering functions and event handlers to be pure Haskell functions.
32 stars 10 forks source link

How do I interact with the URL? #29

Open tysonzero opened 7 years ago

tysonzero commented 7 years ago

Specifically I want to be able to read in the URL (particularly on initial page load) and do actions depending on its value. I also want to be able to write to the URL (like pushState style, where the back button works properly). And I want to be able to listen for the pushState event, that way I can do the right thing whenever a link is pressed, I guess this is (probably?) not strictly necessary if I have the other two things though.

fisx commented 7 years ago

Check out http://blog.wuzzeb.org/full-stack-web-haskell/client.html (search for routing).

I haven't done that yet, and it could certainly be mentioned in the documentation somewhere. Do you have a suggestion where you would have found it before opening this issue? Then we could add it there.

tysonzero commented 7 years ago

I just CTRL+F'd "url" through the source code of the modules I thought might have it lol. So I guess just whatever module seems best to you, or a new module if none of them fit.

tysonzero commented 7 years ago

And then perhaps adding to an example in react-hs-examples

fisx commented 7 years ago

yes, that would be great! ideally, it would be a copy of the example we have, even if it only differs in this one aspect. it's nice to have a basic example where new users don't have to filter out too much code they are not interested in yet.

tysonzero commented 7 years ago

Yeah I think an example that includes basic state manipulation, URLs, localStorage, forms / error handling and ajax requests would be perfect. As it seems to me as though most websites will probably involve all of the above.