admin管理员组文章数量:1244411
Im creating code override to change the text of component, for now it fully replaces the text as Im changing the children
prop, but with replacing children
, it also resets all other props like text styles, is there any other way to change text and keep the styles?
function SetCurrentUsd(props: Props): ReactNode {
const { initialUsd } = props;
const [usd, setUsd] = useState<string | number>("");
useEffect(() => {
// my fetch data logic here
setUsd(data.response)
}, [initialUsd]);
return <>{usd}</>;
}
export function set50Usd(): Override {
return {
children: <SetCurrentUsd initialUsd={50} />,
}
}
export function set100Usd(): Override {
return {
children: <SetCurrentUsd initialUsd={100} />,
}
}
export function set500Usd(): Override {
return {
children: <SetCurrentUsd initialUsd={500} />,
}
}
export function set1000Usd(): Override {
return {
children: <SetCurrentUsd initialUsd={1000} />,
}
}
Im creating code override to change the text of component, for now it fully replaces the text as Im changing the children
prop, but with replacing children
, it also resets all other props like text styles, is there any other way to change text and keep the styles?
function SetCurrentUsd(props: Props): ReactNode {
const { initialUsd } = props;
const [usd, setUsd] = useState<string | number>("");
useEffect(() => {
// my fetch data logic here
setUsd(data.response)
}, [initialUsd]);
return <>{usd}</>;
}
export function set50Usd(): Override {
return {
children: <SetCurrentUsd initialUsd={50} />,
}
}
export function set100Usd(): Override {
return {
children: <SetCurrentUsd initialUsd={100} />,
}
}
export function set500Usd(): Override {
return {
children: <SetCurrentUsd initialUsd={500} />,
}
}
export function set1000Usd(): Override {
return {
children: <SetCurrentUsd initialUsd={1000} />,
}
}
Share
Improve this question
asked Feb 17 at 8:59
user22592696user22592696
214 bronze badges
1 Answer
Reset to default 0You need to pass and accept props in your setter function:
export function set50Usd({...props}:unknown): Override {
return {
...props,
children: <SetCurrentUsd initialUsd={50} />,
}
}
second guess:
export function set50Usd({...props}:unknown): Override {
return {
children: <SetCurrentUsd initialUsd={50} {...props} />,
}
}
本文标签: reactjsReact amp Framer builderuse code override to change textStack Overflow
版权声明:本文标题:reactjs - React & Framer builder, use code override to change text - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740171868a2235691.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论