[英]insert variables in react-markdown
I have a text in markdown and I want to display it in my react-app with variables.我在 markdown 中有一个文本,我想在我的带有变量的 react-app 中显示它。
I tried this way:我试过这样:
<ReactMarkdown
children={contentMd}
renderers={{
someElement: {
instanceLabel: label,
sessionName: test,
mail: emailSupport,
adresse: adressePostale,
},
}}
/>
and in my text in markdown I refer the variables like that:在我的 markdown 文本中,我指的是这样的变量:
outil de gestion par {{instanceLabel}}
But it doesn't work...但它不起作用...
Does someone has a solution?有人有解决方案吗?
thanks.谢谢。
contentMd
is a string
, not JSX. contentMd
是一个string
,而不是 JSX。 You need to interpolate variables, for example this way:您需要插入变量,例如这样:
<ReactMarkdown
children={`outil de gestion par ${instanceLabel}`}
{...props}
/>
Or like so:或者像这样:
<ReactMarkdown
{...props}
>
{`outil de gestion par ${instanceLabel}`}
</ReactMarkdown>
I solved my problem.我解决了我的问题。
Like you said Tymek, contantMd is a string so i used the function replace(), thats'all !!就像你说的 Tymek,contantMd 是一个字符串,所以我使用了 function replace(),仅此而已!
Thanks for your reading感谢您的阅读
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.