lukejacksonn / ijk

Transforms arrays into virtual dom trees; a terse alternative to JSX and h
MIT License
467 stars 17 forks source link

Using with @hyperapp/router #23

Open slacktracer opened 6 years ago

slacktracer commented 6 years ago

I was unable so far to find a way to use ijk with @hyperapp/router (entirely). Have you ever?

I thought was almost there but I got stuck on (below):

const view = () =>
  h(
    "div",
    null,
    h(
      "ul",
      null,
      h("li", null, h(Link, { to: "/" }, "Home")),
      h("li", null, h(Link, { to: "/about" }, "About"))
    ),
    h("hr"),
    h(Route, { path: "/", render: home }),
    h(Route, { path: "/about", render: about })
  );

I did not find a way to turn this h(Link, { to: "/" }, "Home") to "ijk"...

And this Link({ to: "/" }) does not seem to work at all...

I'm looking into this for a few days now but I got no more clues at the moment. Are they even compatible? Or, of course they are, and am I just being silly? ¯\(ツ)

lukejacksonn commented 6 years ago

Humm.. I have never tried. But ijk will only accept nodes that are of an Array type. Which means that Link(...) is probably not going to work just like that. It is an interesting problem though. I will take a look when I get some time.

In the mean time.. you could try rewrite the link function in [x, y, z] form; then you can use it!

slacktracer commented 6 years ago

I see. I will also look into it as soon as possible. It seems h call the function if the its first argument is a function... Perhaps if ijk did the same... Or it could interop with h... I really don't know though.

I love ijk style. I love to call it once for the main view and it just works for everything else. I want to keep it that way if I can. =)

lukejacksonn commented 6 years ago

Yeh, I think it is possible.. I just hadn't covered that case. I'd say a check to see if the nodeName is of type function would suffice. Glad you are liking it :)