Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
babel-plugin-react-element-to-jsx-string
Advanced tools
Turn a ReactElement into the corresponding JSX string at build time.
Turn a ReactElement into the corresponding JSX string at build time.
Mark your React Component with the comment /* react-element-to-jsx-string */
:
import React from 'react';
/* react-element-to-jsx-string */
const Article = ({ title, content }) => (
<article>
<h1>{title}</h1>
<p>{content}</p>
</article>
);
export default Article;
And the JSX as string will be added next to your React Component:
import React from 'react';
/* react-element-to-jsx-string */
const Article = ({ title, content }) => (
<article>
<h1>{title}</h1>
<p>{content}</p>
</article>
);
Article.jsxString = "<article>\n <h1>{title}</h1>\n <p>{content}</p>\n</article>";
export default Article;
Node.js v8 or newer is required.
Via the yarn client:
$ yarn add --dev babel-plugin-react-element-to-jsx-string
Via the npm client:
$ npm install --save-dev babel-plugin-react-element-to-jsx-string
{
"plugins": ["babel-plugin-react-element-to-jsx-string"]
}
Add before a React Component a comment with /* react-element-to-jsx-string */
, and the first JSX code will be added as string in a property called jsxString
.
What about changing the default property name? That can be done in two ways:
/* react-element-to-jsx-string: fooBar */
{
"plugins": [["babel-plugin-react-element-to-jsx-string", { "id": "fooBar" }]]
}
Feel free to dive in! Open an issue or submit PRs.
babel-plugin-react-element-to-jsx-string follows the Contributor Covenant Code of Conduct.
FAQs
Turn a ReactElement into the corresponding JSX string at build time.
We found that babel-plugin-react-element-to-jsx-string demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.