-
Hi there - I'm upgrading my codebase from 0.17.4 to 0.18.0 and discovered errors per the following:
This occurs given <line x1={LEFT_MARGIN_X} y1={TOP_MARGIN_Y} x2={LEFT_MARGIN_X} y2={BOTTOM_MARGIN_Y} class="axis-y-line" /> Is it that I must use an explicit Can you please confirm on how I migrate this change? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey 👋
Yes, Yew used to call If your const/static variables are only being used in the In your Before: use yew::prelude::*;
#[derive(Clone, Properties)]
pub struct ModelProps {
text: String,
} After: use std::borrow::Cow;
use yew::prelude::*;
#[derive(Clone, Properties)]
pub struct ModelProps {
text: Cow<'static, str>,
} |
Beta Was this translation helpful? Give feedback.
Hey 👋
Yes, Yew used to call
ToString::to_string
for you before 0.18.0, which in this case is convenient, however, when passing something like an ownedString
to a childComponent
this would cause theString
to be cloned when it might only need to be borrowed. So Yew 0.18.0 usesCow
s under the hood so that ownedString
s can be borrowed and only cloned on write.If your const/static variables are only being used in the
html!
macro for setting attributes then you can consider using&'static
to avoid theto_string
calls.In your
Properties
, to avoid needless cloning, you can change theString
fields toCow<'static, str>
:Bef…