Skip to content

Commit ac06cb9

Browse files
Merge branch 'master' of github.com:transitive-bullshit/create-react-library
* 'master' of github.com:transitive-bullshit/create-react-library: Change ExampleComponent import to named import in template test Change template component to functional; change example App component to functional
2 parents fbe5d10 + 7a7c233 commit ac06cb9

File tree

3 files changed

+19
-29
lines changed

3 files changed

+19
-29
lines changed

template/default/example/src/App.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import React, { Component } from 'react';
1+
import React from 'react';
22
import './App.css';
33

4-
import ExampleComponent from '{{name}}';
4+
import { ExampleComponent } from '{{name}}';
55

6-
class App extends Component {
7-
render() {
8-
return <ExampleComponent text='Modern React component module' />;
9-
}
10-
}
6+
const App = () => {
7+
return <ExampleComponent text='Modern React component module' />;
8+
};
119

1210
export default App;

template/default/src/index.js

+10-18
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
1-
import React, { Component } from 'react'
2-
import PropTypes from 'prop-types'
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
33

4-
import styles from './styles.css'
4+
import styles from './styles.css';
55

6-
export default class ExampleComponent extends Component {
7-
static propTypes = {
8-
text: PropTypes.string
9-
}
6+
export const ExampleComponent = () => {
7+
const { text } = this.props;
108

11-
render() {
12-
const {
13-
text
14-
} = this.props
9+
return <div className={styles.test}>Example Component: {text}</div>;
10+
};
1511

16-
return (
17-
<div className={styles.test}>
18-
Example Component: {text}
19-
</div>
20-
)
21-
}
22-
}
12+
ExampleComponent.propTypes = {
13+
text: PropTypes.string
14+
};

template/default/src/test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import ExampleComponent from './'
1+
import { ExampleComponent } from './';
22

33
describe('ExampleComponent', () => {
44
it('is truthy', () => {
5-
expect(ExampleComponent).toBeTruthy()
6-
})
7-
})
5+
expect(ExampleComponent).toBeTruthy();
6+
});
7+
});

0 commit comments

Comments
 (0)