Skip to content
This repository was archived by the owner on Apr 1, 2023. It is now read-only.

Commit 977bd4c

Browse files
Merge pull request #196 from transitive-bullshit/v2-hooks
Change templates to use hooks
2 parents 8d80a14 + 8333876 commit 977bd4c

File tree

4 files changed

+18
-37
lines changed

4 files changed

+18
-37
lines changed
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
import React, { Component } from 'react'
1+
import React from 'react'
22
import './App.css'
33

44
import ExampleComponent from '{{name}}'
55

6-
class App extends Component {
7-
render() {
8-
return (
9-
<ExampleComponent text='Create React Library Example' />
10-
)
11-
}
12-
}
6+
const App = () =>
7+
<ExampleComponent text='Create React Library Example' />
138

149
export default App

packages/create-react-library/template/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@
2525
"peerDependencies": {
2626
"react": ">=16.8"
2727
},
28+
{{#unless typescript}}
2829
"dependencies": {
2930
"prop-types": "^15.7.2"
3031
},
32+
{{/unless}}
3133
"devDependencies": {
3234
{{#if typescript}} "@types/jest": "^24.0.11",
3335
"@types/react": "^16.8.13",
Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
1-
import React, { Component } from 'react'
1+
import React from 'react'
22
import PropTypes from 'prop-types'
33

44
import styles from './styles.css'
55

6-
export default class ExampleComponent extends Component {
7-
static propTypes = {
8-
text: PropTypes.string
9-
}
6+
const ExampleComponent = ({ text }) =>
7+
<div className={styles.test}>Example Component: {text}</div>
108

11-
render() {
12-
const {
13-
text
14-
} = this.props
159

16-
return (
17-
<div className={styles.test}>
18-
Example Component: {text}
19-
</div>
20-
)
21-
}
10+
ExampleComponent.propTypes = {
11+
text: PropTypes.string
2212
}
13+
14+
export default ExampleComponent
Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
import React from 'react'
2-
32
import styles from './styles.css'
43

5-
export type Props = { text: string }
4+
const ExampleComponent: React.FC<ExampleComponentProps> = ({text}) =>
5+
<div className={styles.test}>Example Component: {text}</div>
66

7-
export default class ExampleComponent extends React.Component<Props> {
8-
render() {
9-
const {
10-
text
11-
} = this.props
7+
type ExampleComponentProps = {
8+
text: string
9+
}
1210

13-
return (
14-
<div className={styles.test}>
15-
Example Component: {text}
16-
</div>
17-
)
18-
}
19-
}
11+
export default ExampleComponent

0 commit comments

Comments
 (0)