!LtIECwsjkkjinzHTTB:matrix.org

Support/Help

948 Members
6 Servers

Load older messages


SenderMessageTime
12 Jan 2024
@_discord_1191787143169851574:t2bot.iodementeddddd i dont have that commented now 21:07:13
@_discord_1191787143169851574:t2bot.iodementeddddd its cuz i dont have ModalProvider implemented anywhere i think 21:07:35
@_discord_326088262118670337:t2bot.iokirillsemyonkin yeah i think you did a <ContextProvider> directly in app 21:07:53
@_discord_1191787143169851574:t2bot.iodementeddddd yes i did 21:08:00
@_discord_1191787143169851574:t2bot.iodementeddddd and inside it i put ItemsList 21:08:29
@_discord_326088262118670337:t2bot.iokirillsemyonkin my ModalProvider component was supposed to just replace that by bringing all the related logic and state into a small simple component 21:08:32
@_discord_1191787143169851574:t2bot.iodementeddddd u mean i was supposed to place ContextProvider into ModalProvider 21:08:48
@_discord_1191787143169851574:t2bot.iodementeddddd
#[function_component]
pub fn ModalProvider(ChildrenProps { children }: &ChildrenProps) -> Html {
    let modal_content = use_state(|| html! {});
    let visible = use_state(|| false);
    html! {
        <>
            if *visible {
                <div class="modal-content">
                    { (*modal_content).clone() } // render some modal content
                </div>
            }
            { (*children).clone() } // just pass through
        </>
    }
}
21:08:59
@_discord_1191787143169851574:t2bot.iodementeddddd this is my ModalProvider 21:09:02
@_discord_1191787143169851574:t2bot.iodementeddddd rn 21:09:07
@_discord_326088262118670337:t2bot.iokirillsemyonkin yes 21:09:13
@_discord_1191787143169851574:t2bot.iodementeddddd so was i supposed to use use_modal in there 21:09:22
@_discord_326088262118670337:t2bot.iokirillsemyonkin let context = ...; and ContextProvider 21:09:26
@_discord_326088262118670337:t2bot.iokirillsemyonkin use_modal is for the children 21:09:31
@_discord_1191787143169851574:t2bot.iodementeddddd ok but 21:09:56
@_discord_1191787143169851574:t2bot.iodementeddddd if i do that 21:10:22
@_discord_1191787143169851574:t2bot.iodementeddddd then ItemsList wont have the context to call use_modal 21:10:31
@_discord_1191787143169851574:t2bot.iodementeddddd and what do i do with this code if i move visible and modal_content to create context
if *visible {
    <div class="modal-content">
        { (*modal_content).clone() } // render some modal content
    </div>
}
{ (*children).clone() } // just pass through
21:11:00
@_discord_326088262118670337:t2bot.iokirillsemyonkin you would do <ModalProvider><ItemsList /></ModalProvider> though? 21:11:06
@_discord_1191787143169851574:t2bot.iodementeddddd hmm alright 21:11:25
@_discord_1191787143169851574:t2bot.iodementeddddd ig that makes sense 21:11:32
@_discord_1191787143169851574:t2bot.iodementeddddd will probably make more sense later 21:11:39
@_discord_1191787143169851574:t2bot.iodementeddddd what about this 21:11:44
@_discord_326088262118670337:t2bot.iokirillsemyonkin oh you can make a
let context = ModalHandle {
    visible: visible.clone(),
    modal_content: modal_content.clone(),
};
21:12:19
@_discord_1191787143169851574:t2bot.iodementeddddd and then 21:12:31
@_discord_1191787143169851574:t2bot.iodementeddddd do i put that code into the ContextProvider? 21:12:37
@_discord_326088262118670337:t2bot.iokirillsemyonkin you can replace the <#> fragment with <ContextProvider...> 21:13:03
@_discord_326088262118670337:t2bot.iokirillsemyonkin * you can replace the <#> fragment (thats the name for the <#>) with <ContextProvider...> 21:13:18
@_discord_1191787143169851574:t2bot.iodementeddddd alright 21:13:19
@_discord_1191787143169851574:t2bot.iodementeddddd done 21:13:19

Show newer messages


Back to Room ListRoom Version: 6