Skip to content

Commit 140c33f

Browse files
committed
Refactored the code
1 parent 9f67731 commit 140c33f

13 files changed

+29
-46
lines changed

app/components/App/AppView.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ import HelpButton from '../HelpButton';
55

66
export default () =>
77
<div className="container">
8-
<Title />
9-
<HelpButton />
8+
<Title/>
9+
<HelpButton/>
1010
</div>;

app/components/App/AppView.native.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ import HelpButton from '../HelpButton';
88

99
export default () =>
1010
<View style={styles.container}>
11-
<Title />
12-
<HelpButton />
11+
<Title/>
12+
<HelpButton/>
1313
</View>;

app/components/App/index.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
import React from 'react';
21
import AppView from './AppView';
3-
4-
export default () => <AppView />;
2+
export default AppView;

app/components/HelpButton/AbstractHelpButtonContainer.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import HelpButtonView from './HelpButtonView';
33

44
export default class AbstractHelpButtonContainer extends React.Component {
55
constructor(props) {
6-
if (new.target === AbstractHelpButtonContainer) {
7-
throw new TypeError('Cannot construct AbstractHelpButtonContainer instances directly');
8-
}
6+
// new.target is not working on Android
7+
// if (new.target === AbstractHelpButtonContainer) {
8+
// throw new TypeError('Cannot construct AbstractHelpButtonContainer instances directly');
9+
// }
10+
911
super(props);
1012

1113
this.onClick = this.onClick.bind(this);
@@ -16,8 +18,6 @@ export default class AbstractHelpButtonContainer extends React.Component {
1618
}
1719

1820
render() {
19-
return (
20-
<HelpButtonView onClick={this.onClick} />
21-
);
21+
return <HelpButtonView onClick={this.onClick}/>;
2222
}
2323
}
+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import React from 'react';
22

33
export default props =>
4-
<button className="help-button" onClick={props.onClick}>Help</button>;
4+
<button className="help-button" onClick={props.onClick}>
5+
Help
6+
</button>;

app/components/HelpButton/HelpButtonView.native.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import { Alert } from 'react-native';
32
import Button from 'react-native-button';
43

54
import styles from '../../native/styles';

app/components/HelpButton/index.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
import React from 'react';
21
import HelpButtonContainer from './HelpButtonContainer';
3-
4-
export default () => <HelpButtonContainer />;
2+
export default HelpButtonContainer;

app/components/Title/TitleView.android.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ import { Text } from 'react-native';
44
import styles from '../../native/styles';
55

66
export default () =>
7-
<Text style={styles.title}>React Native Code Reuse (Android)</Text>;
7+
<Text style={styles.title}>
8+
React Native Code Reuse (Android)
9+
</Text>;

app/components/Title/TitleView.ios.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ import { Text } from 'react-native';
44
import styles from '../../native/styles';
55

66
export default () =>
7-
<Text style={styles.title}>React Native Code Reuse (iOS)</Text>;
7+
<Text style={styles.title}>
8+
React Native Code Reuse (iOS)
9+
</Text>;

app/components/Title/TitleView.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import React from 'react';
22

33
export default () =>
4-
<h1 className="title">React Native Code Reuse (Web)</h1>;
4+
<h1 className="title">
5+
React Native Code Reuse (Web)
6+
</h1>;

app/components/Title/index.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
import React from 'react';
21
import TitleView from './TitleView';
3-
4-
export default () => <TitleView />;
2+
export default TitleView;

index.android.js

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
import React from 'react';
2-
import {AppRegistry} from 'react-native';
2+
import { AppRegistry } from 'react-native';
33

44
import App from './app/components/App';
5-
6-
export default class ReactNativeCodeReuse extends React.Component {
7-
render() {
8-
return (
9-
<App />
10-
);
11-
}
12-
}
13-
14-
AppRegistry.registerComponent('ReactNativeCodeReuse', () => ReactNativeCodeReuse);
5+
AppRegistry.registerComponent('ReactNativeCodeReuse', () => App);

index.ios.js

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
import React from 'react';
2-
import {AppRegistry} from 'react-native';
2+
import { AppRegistry } from 'react-native';
33

44
import App from './app/components/App';
5-
6-
export default class ReactNativeCodeReuse extends React.Component {
7-
render() {
8-
return (
9-
<App />
10-
);
11-
}
12-
}
13-
14-
AppRegistry.registerComponent('ReactNativeCodeReuse', () => ReactNativeCodeReuse);
5+
AppRegistry.registerComponent('ReactNativeCodeReuse', () => App);

0 commit comments

Comments
 (0)