!LtIECwsjkkjinzHTTB:matrix.org

Support/Help

255 Members
3 Servers

Load older messages


SenderMessageTime
26 May 2022
@_discord_120619855056601088:t2bot.ioWorldSEnder#8649 where'd you get that from, multi-line string literals work like they do in rust 22:55:31
@_discord_770804101332074547:t2bot.ioDarkuss#3803 sorry, i come from html 22:58:25
@_discord_120619855056601088:t2bot.ioWorldSEnder#8649 yeah, there are slight differences between html and html! to bridge the difference to rust 😄 22:59:02
@_discord_770804101332074547:t2bot.ioDarkuss#3803 ok so the next problem i'm facing is that it seems that { var } sanitizes the variable content and displays content as is, is there a way to turn that off so html tags in the variable are rendered? 23:02:56
@_discord_120619855056601088:t2bot.ioWorldSEnder#8649 that's by design to protect against xss 23:04:30
@_discord_120619855056601088:t2bot.ioWorldSEnder#8649 and no, there's no magic __innerHtml, you'll have to parse it yourself, or follow the inner_html example https://github.com/yewstack/yew/tree/master/examples/inner_html 23:05:27
@_discord_770804101332074547:t2bot.ioDarkuss#3803 well that seems a little bit inconvenient 23:06:46
@_discord_178890871318642688:t2bot.ioInnominus#5664 What's the overhead cost of spinning up an agent? 23:08:47
@_discord_120619855056601088:t2bot.ioWorldSEnder#8649 script injection is a bit more than a little bit inconvenient 23:10:27
@_discord_770804101332074547:t2bot.ioDarkuss#3803 sure, but i definitely can imagine a scenario where someone would want to use that 23:11:47
@_discord_770804101332074547:t2bot.ioDarkuss#3803 maybe lock it behind a crate feature 23:11:57
@_discord_120619855056601088:t2bot.ioWorldSEnder#8649 if you want it, the workaround is in the example. But it's a extremely large footgun overall 23:14:51
@_discord_142479917471367169:t2bot.ioaftix I'm stuck with this testing thing, any ideas how to make my component call a mock function instead of trying to reach my API when i'm running tests? 23:23:55
@_discord_142479917471367169:t2bot.ioaftix I tried to make a Box<dyn ApiCaller> but async_trait wouldn't behave the same as top-level async fn and that isn't something I can use prop_or with 23:24:42
@_discord_142479917471367169:t2bot.ioaftix I can think of using mock: bool in the props and deciding in the component but that's ugly and couples test to the component 23:25:49
@_discord_120619855056601088:t2bot.ioWorldSEnder#8649 without detailed design, you could #[cfg(test)] some top-level function that actually makes the request and switch to a mock version 23:25:59
@_discord_142479917471367169:t2bot.ioaftix That would only allow me to return 1 thing from the mock function, but what if i need tests that mock different API responses? 23:28:30
@_discord_120619855056601088:t2bot.ioWorldSEnder#8649 true, though perhaps you can pass stuff through a ContextProvider 23:29:40
@_discord_120619855056601088:t2bot.ioWorldSEnder#8649 anyway, sleep calls again for me 😉 23:29:47
@_discord_142479917471367169:t2bot.ioaftix that would work! My API calls need the context anyways usually 23:29:56
27 May 2022
@_discord_178890871318642688:t2bot.ioInnominus#5664 How does use_effect_with_deps actually run 00:33:13
@_discord_178890871318642688:t2bot.ioInnominus#5664 does it not run on the first render? 00:33:18
@_discord_178890871318642688:t2bot.ioInnominus#5664 How do I make it do that? It seems to only run on the second render when something changes 00:33:29
@_discord_178890871318642688:t2bot.ioInnominus#5664 ah, I see 00:43:44
@_discord_178890871318642688:t2bot.ioInnominus#5664 sort of lel 01:01:52
@_discord_178890871318642688:t2bot.ioInnominus#5664 would it be bad practice to use use_effect and move in a boolean that will dictate whether to run use_effect or not? 01:31:43
@_discord_178890871318642688:t2bot.ioInnominus#5664 Actually that sounds even more pointless. Doesn't everything in the function get re-run every render? I could just omit use_effect anyway 01:32:37
@_discord_707257809762517022:t2bot.iojetli there's a hook use_mount from yew-hooks which does this job, it only executes callback when a component is first mount, example: https://github.com/jetli/yew-hooks/blob/main/examples/yew-app/src/routes/hooks/use_mount.rs
or you can simply use use_effect_with_deps which depends on () like this:
use_effect_with_deps(move |_| {
    // do something
    || ()
}, ());
02:49:37
@_discord_178890871318642688:t2bot.ioInnominus#5664 Interesting, use effect with deps wasn't working for me when I first tried 02:49:50
@_discord_178890871318642688:t2bot.ioInnominus#5664 I wasn't using a blank '()' as the dependent though. Cheers 02:50:11

There are no newer messages yet.


Back to Room List