
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
npm script to generate react component similar to ng-generate.
Generate React components in an opinonated way taught at _nology. This includes seperating components into different folders depending on whether they are presentational or container components, referred as "containers" and "components" and is outlined below.
At _nology we use scss for all React components so we use scss instead of css.
Files are generated with basic boilerplate code as follows:
Component.jsx:
import React from "react";
import styles from "./Component.module.scss";
const Component = () => {
return (
<>
<p>Component works</p>
</>
);
};
export default Component;
OR
import React, { Component } from "react";
import styles from "./Component.module.scss";
class Component extends Component {
render() {
return (
<>
<p>Component works</p>
</>
);
}
}
export default Component;
Component.test.js:
import React from "react";
import { render } from "@testing-library/react";
import Component from "./Component";
describe("Component tests", () => {
it("should render", () => {
expect(render(<Component />)).toBeTruthy();
});
});
index.js:
import Component from "./Component";
export default Component;
npm install --save-dev mkrc
or
yarn add mkrc --dev
|--src
| +-components
| +-<react components go here>
| +-Component.jsx
| +-Component.module.scss
| +-Component.test.js
| +-index.js
| +-containers
| +-<App>
| +-App.jsx
| +-App.module.scss
The script accepts 2 parameters:
First is containing folder in src. e.g. components or containers.
Second is the name of the component.
There are 3 flags.
| Flag | Option | Description |
|---|---|---|
| -f | --function | Creates a functional component |
| -c | --class | Creates a class component |
| -t | --tsfunction | Creates a TypeScript functional component |
If no flag is given then a JSX functional component is generated by default
In the command line enter the following if using npm:
npm run mkrc <component-type> <component-name>
or the following if using yarn:
yarn mkrc <component-type> <component-name>
If the above commands are not working you may have to set up the command. Add the following script to your package.json file:
"scripts": {
"mkrc": "./node_modules/.bin/mkrc"
},
An optional way to use mkrc is to install it globally using:
npm install -g mkrc
or
yarn global add mkrc
This will allow you to use mkrc anywhere in nearly the exact same way by omitting yarn or npm run from the beginning of the command:
mkrc <component-type> <component-name>
Run script by entering:
npm test
This will generate a "Square" component in the "component" folder
FAQs
Create React components similar to ng-generate
We found that mkrc 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.