-
Notifications
You must be signed in to change notification settings - Fork 11
Keyed nodes #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @daig , I haven't used keyed elements in Elm, but this seems like something worth implementing. I like the idea of translating a node with a Can you send me a working example in plain Elm? |
The example I'm working with is: import List
import Uuid exposing (Uuid)
import Html exposing (li)
import Note
import Html.Keyed as Keyed
type alias Notes = List (Uuid,Note.Model)
view : Notes -> Html Msg
view notes = Keyed.ul [] (notes |> List.map (\(id,note) -> (toString id, li [] [Note.view note]))) |
Here's your example in import Html
import Html.Attributes
import Html.Keyed
import List
import Uuid exposing (Uuid)
import Note
type alias Notes = List (Uuid,Note.Model)
view : Notes -> Html Msg
view notes =
let
items = notes |> List.map (\(id,note) -> <li key={toString id}>{Note.view note}</li>)
in
<ul keyed>{:items}</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In JSX there's special syntax for keyed nodes in a list:
There is functionality for keyed nodes in Elm but so far as I can tell they use a different datastructure from normal nodes. So, it will be tricky to implement this transform as it
A possible first step is, rather than nesting like above (#9), simply translate
<li key={k}>{stuff}</li>
to(k,li [] [stuff])
and require the keyed parent node explicitly.The text was updated successfully, but these errors were encountered: