Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

add-react-component

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

add-react-component - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

1

components/component-index.js

@@ -5,3 +5,2 @@ const path = require('path')

module.exports = ComponentIndex

@@ -8,0 +7,0 @@

5

components/function-component.js
const path = require('path')
const fs = require('fs')
const toTitleCase = require('titlecase')

@@ -15,2 +16,4 @@ module.exports = FunctionComponent

function templateWithCSS (name) {
const proper = toTitleCase(name)
return `import React from 'react'

@@ -20,3 +23,3 @@

export default function ${name} (props) {
export default function ${proper} (props) {
return (

@@ -23,0 +26,0 @@ <div className={style.container}>${name}</div>

const path = require('path')
const fs = require('fs')
const toTitleCase = require('titlecase')

@@ -15,2 +16,4 @@ module.exports = PureComponent

function templateWithCSS (name) {
const proper = toTitleCase(name)
return `import React, { PureComponent } from 'react'

@@ -20,3 +23,3 @@

class ${name} extends PureComponent {
class ${proper} extends PureComponent {
render () {

@@ -29,3 +32,3 @@ return (

export default ${name}
export default ${proper}
`

@@ -32,0 +35,0 @@ }

{
"name": "add-react-component",
"version": "1.0.0",
"version": "1.1.0",
"description": "Create React Component CLI",

@@ -5,0 +5,0 @@ "repository": {

@@ -11,33 +11,62 @@ # add-react-component

## Usage
<br>
```
# Generate PureComponent and shallow render test
$ add-react-component
## Usage
# Generate PureComponent and shallow render test with stylesheet
$ add-react-component -c
### Generate Class PureComponent
# Generate Functional Component and shallow render test with stylesheet
$ add-react-component -c -f
```
Run
## Example
```add-react-component ComponentName```
```sh
add-react-component example -c
```
Generates `example` folder with the following:
This will create a folder of your component name, and a **Class PureComponent** js file with the same name.
`index.js`
```js
import Example from './example.js'
<br>
export default Example
```
### Generate Function Component
`style.css`
```css
.container {}
```
Run
`example.js`
```js
import React, { PureComponent } from 'react'
```add-react-component ComponentName -f```
import style from './style.css'
This will create a folder of your component name, and **Function Component** js file of the same name.
class Example extends PureComponent {
render () {
return (
<div className={style.container}>test</div>
)
}
}
<br>
### Generate PureComponent or Function Component with a CSS file
export default Example
```
Run
`example.test.js`
```
import React from 'react'
import { shallow } from 'enzyme'
```add-react-component ComponentName -p -c```
import Example from './example.js'
This will create a folder of your component name, and component (Functional if ```-f```) js file of the same name, and a css file of the same name.
it('renders without props', () => {
shallow(<Example />)
})
```

@@ -44,0 +73,0 @@ ## License

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc