Skip to content
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

Slow rendering #353

Open
djordjedjukic opened this issue May 1, 2024 · 2 comments
Open

Slow rendering #353

djordjedjukic opened this issue May 1, 2024 · 2 comments

Comments

@djordjedjukic
Copy link

Hi,

I have an issue with slow rendering when the page has more elements.
I am creating a clone of one website which is working nicely.

So I am rendering 200 cards that represent Lego set info. Also when I am filling the dropdown with 450 elements, the page becomes unresponsive. I will share the gif of what that looks like and the code.

I don't know if that is an expected behavior of bolero/blazor or if I am doing something wrong?

This example is without dropdown because it can't render dropdown at all.

ScreenRecording2024-05-01at14 13 31-ezgif com-video-to-gif-converter

type Page = Template<"Pages/Sets/data.html">

let showSet (set: Set) =
    Page
        .SetData()
        .SetNumber(set.Number)
        .SetName(set.Name)
        .SetImageUrl(set.ImageUrl)
        .ThemeName(set.ThemeName)
        .Year(set.Year.ToString())
        .NumberOfParts(set.NumberOfParts.ToString())
        .Elt()
        
        let listSets model dispatch =
    let toggleDropdown _ = dispatch ToggleDropdown
    let triggerSearch dispatch =
        fun (e: ChangeEventArgs) ->
            let value = e.Value.ToString()
            dispatch (SearchSets value)

    let dropdownVisibilityClass = if model.IsDropdownOpen then "" else "hidden"

    Page()
        (*.DropdownOptions(
            forEach model.Themes <| renderOption
                
        )*)
        .TriggerSearch(triggerSearch dispatch)
        .ToggleDropdown(toggleDropdown)
        .DropdownVisible(dropdownVisibilityClass)
        .Rows(
            cond model.Sets
            <| function
                | None -> empty ()
                | Some sets -> forEach sets <| showSet
        )
        .Elt()

let view model dispatch = listSets model dispatch

@Tarmil
Copy link
Member

Tarmil commented May 1, 2024

When your page contains many items like this, it's usually a good idea to put each in a Component to avoid re-rendering everything on every change. https://fsbolero.io/docs/Elmish#view-components

@djordjedjukic
Copy link
Author

Yes, I noticed that things re-render very often without need, like sidebar, menu items etc. I will use view-components.

But I don't think that will speed up rendering this page or filling the dropdown, or I am wrong?

Also a question, can view-components be used with templates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants