我希望将React Create元素代码转换为JSX。
我从这个问题中找到了这个插件https://www.npmjs.com/package/babel-plugin-transform-react-createelement-to-jsx Is there a tool to convert React Elements javascript code to JSX
安装此babel-plugin-transform-react-createelement-to-jsx并使用以下代码创建.babelrc文件:
int main(int argc, string argv[]) {
string hash = argv[1]; // Read from argv
crack_password(hash);
}
void crack_password(char * hash) {
printf("%d\n", hash); // prints correctly.
string * password_guess; // = some functionality, hash doesn't change
match_password(password_guess, hash);
}
match_password(char * password_guess, char * hash) {
printf("%d\n", hash) // prints correctly.
char first_two_letters[2] = "";
append(first_two_letters, hash[0]);
printf("Hash: %s\n", hash);
append(first_two_letters, hash[1]);
printf("%d\n", first_two_letters); // prints first two letters of the hash.
printf("%d\n", hash); // hash null here.
}
void append(char * s, char c) {
int len = strlen(s);
s[len] = c;
s[len + 1] = '\0';
}
使用代码创建test.js:
{
"plugins": [ "transform-react-createelement-to-jsx" ]
}
我想知道如何使用此插件和任何其他可用于转换的工具来转换此代码?