简体   繁体   English

将 React 组件字符串转换为 JSX

[英]Convert React components String to JSX

I have a string of React components.我有一串 React 组件。

//X.jsx
import "./x.css"
const X =({x}) =><div className={"x"} >{x}</div>

//Y.jsx
import "./y.css"
const Y =({y}) =><div className={"y"} >{y}</div>

`<X x={"x"}/> <Y x={"y"}/>`

I want to convert it to jsx how to do it?我想把它转成jsx怎么办?

I think the example you provided would inject the CSS declarations into the classname, no?我认为您提供的示例会将 CSS 声明注入类名,不是吗? That doesn't seem like what you want.这似乎不是你想要的。 Maybe consult this page and explore an avenue where you are importing the css in as a module to the given component and adding the relevant classname to it from the file.也许查阅此页面并探索您将 css 作为模块导入给定组件并从文件中添加相关类名的途径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM