Skip to content

Commit f193aa3

Browse files
committed
Add second component and implement routing using react-router
1 parent a2ebba1 commit f193aa3

File tree

7 files changed

+133
-6
lines changed

7 files changed

+133
-6
lines changed

Diff for: package.json

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
"react-native-elements": "^1.0.0-beta7",
5555
"react-native-vector-icons": "^6.1.0",
5656
"react-native-web": "0.8.4",
57+
"react-router-dom": "^4.3.1",
58+
"react-router-native": "^4.3.0",
5759
"resolve": "1.6.0",
5860
"style-loader": "0.19.0",
5961
"sw-precache-webpack-plugin": "0.11.4",

Diff for: src/App.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import React, { Component } from 'react';
22
import Home from './Components/Home';
3+
import CommitList from './Components/Commit/CommitList';
4+
import { Route, Router, Switch } from './Utils/Routing';
35

46
class App extends Component {
57
render() {
68
return (
7-
<Home />
9+
<Router>
10+
<Switch>
11+
<Route exact path="/" component={Home} />
12+
<Route exact path="/commit" component={CommitList} />
13+
</Switch>
14+
</Router>
815
);
916
}
1017
}

Diff for: src/Components/Commit/CommitList.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
import { Text, View } from 'react-native';
3+
4+
import styles from '../Shared.style';
5+
6+
const CommitList = () => (
7+
<View style={styles.container}>
8+
<Text>Placeholder for second screen</Text>
9+
</View>
10+
);
11+
12+
export default CommitList

Diff for: src/Components/Home.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@ import { View } from 'react-native';
33
import { Input, Button } from 'react-native-elements';
44

55
import styles from './Shared.style';
6+
import { withRouter } from '../Utils/Routing';
67

78
class Home extends PureComponent {
9+
onPressButton = () => {
10+
// Go to Commit screen
11+
this.props.history.push('/commit');
12+
}
13+
814
render() {
915
const { input, button } = styles;
1016

@@ -26,15 +32,16 @@ class Home extends PureComponent {
2632
title='SUBMIT'
2733
icon={{
2834
color: 'white',
29-
name:'paper-plane',
35+
name: 'paper-plane',
3036
size: 15,
3137
type: 'font-awesome'
3238
}}
3339
buttonStyle={button.containerStyle}
40+
onPress={this.onPressButton}
3441
/>
3542
</View>
3643
);
3744
}
3845
}
3946

40-
export default Home;
47+
export default withRouter(Home);

Diff for: src/Utils/Routing.native.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export {
2+
NativeRouter as Router, // Rename
3+
Link,
4+
Route,
5+
Switch,
6+
withRouter
7+
} from 'react-router-native';

Diff for: src/Utils/Routing.web.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export {
2+
BrowserRouter as Router,
3+
Link,
4+
Route,
5+
Switch,
6+
withRouter
7+
} from 'react-router-dom';

Diff for: yarn.lock

+88-3
Original file line numberDiff line numberDiff line change
@@ -4043,6 +4043,17 @@ he@1.1.x:
40434043
version "1.1.1"
40444044
resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd"
40454045

4046+
history@^4.7.2:
4047+
version "4.7.2"
4048+
resolved "https://registry.yarnpkg.com/history/-/history-4.7.2.tgz#22b5c7f31633c5b8021c7f4a8a954ac139ee8d5b"
4049+
integrity sha512-1zkBRWW6XweO0NBcjiphtVJVsIQ+SXF29z9DVkceeaSLVMFXHool+fdCZD4spDCfZJCILPILc3bm7Bc+HRi0nA==
4050+
dependencies:
4051+
invariant "^2.2.1"
4052+
loose-envify "^1.2.0"
4053+
resolve-pathname "^2.2.0"
4054+
value-equal "^0.4.0"
4055+
warning "^3.0.0"
4056+
40464057
hmac-drbg@^1.0.0:
40474058
version "1.0.1"
40484059
resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1"
@@ -4051,6 +4062,11 @@ hmac-drbg@^1.0.0:
40514062
minimalistic-assert "^1.0.0"
40524063
minimalistic-crypto-utils "^1.0.1"
40534064

4065+
hoist-non-react-statics@^2.5.0:
4066+
version "2.5.5"
4067+
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz#c5903cf409c0dfd908f388e619d86b9c1174cb47"
4068+
integrity sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw==
4069+
40544070
home-or-tmp@^2.0.0:
40554071
version "2.0.0"
40564072
resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8"
@@ -4315,7 +4331,7 @@ interpret@^1.0.0:
43154331
version "1.1.0"
43164332
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.1.0.tgz#7ed1b1410c6a0e0f78cf95d3b8440c63f78b8614"
43174333

4318-
invariant@^2.2.0, invariant@^2.2.2:
4334+
invariant@^2.2.0, invariant@^2.2.1, invariant@^2.2.2, invariant@^2.2.4:
43194335
version "2.2.4"
43204336
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6"
43214337
dependencies:
@@ -5051,6 +5067,11 @@ js-tokens@^3.0.0, js-tokens@^3.0.2:
50515067
version "3.0.2"
50525068
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
50535069

5070+
"js-tokens@^3.0.0 || ^4.0.0":
5071+
version "4.0.0"
5072+
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
5073+
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
5074+
50545075
js-yaml@^3.4.3, js-yaml@^3.7.0, js-yaml@^3.9.1:
50555076
version "3.12.0"
50565077
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.0.tgz#eaed656ec8344f10f527c6bfa1b6e2244de167d1"
@@ -5414,6 +5435,13 @@ loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1:
54145435
dependencies:
54155436
js-tokens "^3.0.0"
54165437

5438+
loose-envify@^1.2.0:
5439+
version "1.4.0"
5440+
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
5441+
integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==
5442+
dependencies:
5443+
js-tokens "^3.0.0 || ^4.0.0"
5444+
54175445
loud-rejection@^1.0.0:
54185446
version "1.6.0"
54195447
resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f"
@@ -6331,7 +6359,7 @@ path-to-regexp@0.1.7:
63316359
version "0.1.7"
63326360
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c"
63336361

6334-
path-to-regexp@^1.0.1:
6362+
path-to-regexp@^1.0.1, path-to-regexp@^1.7.0:
63356363
version "1.7.0"
63366364
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.7.0.tgz#59fde0f435badacba103a84e9d3bc64e96b9937d"
63376365
dependencies:
@@ -6815,7 +6843,7 @@ prop-types@^15.5.10, prop-types@^15.5.8, prop-types@^15.6.0:
68156843
loose-envify "^1.3.1"
68166844
object-assign "^4.1.1"
68176845

6818-
prop-types@^15.6.2:
6846+
prop-types@^15.6.1, prop-types@^15.6.2:
68196847
version "15.6.2"
68206848
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.2.tgz#05d5ca77b4453e985d60fc7ff8c859094a497102"
68216849
integrity sha512-3pboPvLiWD7dkI3qf3KbUe6hKFKa52w+AE0VCqECtf+QHAKgOL37tTaNCnuX1nAAQ4ZhyP+kYVKf8rLmJ/feDQ==
@@ -7115,6 +7143,39 @@ react-proxy@^1.1.7:
71157143
lodash "^4.6.1"
71167144
react-deep-force-update "^1.0.0"
71177145

7146+
react-router-dom@^4.3.1:
7147+
version "4.3.1"
7148+
resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-4.3.1.tgz#4c2619fc24c4fa87c9fd18f4fb4a43fe63fbd5c6"
7149+
integrity sha512-c/MlywfxDdCp7EnB7YfPMOfMD3tOtIjrQlj/CKfNMBxdmpJP8xcz5P/UAFn3JbnQCNUxsHyVVqllF9LhgVyFCA==
7150+
dependencies:
7151+
history "^4.7.2"
7152+
invariant "^2.2.4"
7153+
loose-envify "^1.3.1"
7154+
prop-types "^15.6.1"
7155+
react-router "^4.3.1"
7156+
warning "^4.0.1"
7157+
7158+
react-router-native@^4.3.0:
7159+
version "4.3.0"
7160+
resolved "https://registry.yarnpkg.com/react-router-native/-/react-router-native-4.3.0.tgz#4ad821f0543a96694d8ec4ee735a299e330181a1"
7161+
integrity sha512-G+djpkW0zMs7iNgL33uHTsNOmkhl0NxHYzGaG/C4G3dCNV4RPg20OLvTHHiZ20X9921sq98nPfTNAjCHNrGYjw==
7162+
dependencies:
7163+
prop-types "^15.6.1"
7164+
react-router "^4.3.0"
7165+
7166+
react-router@^4.3.0, react-router@^4.3.1:
7167+
version "4.3.1"
7168+
resolved "https://registry.yarnpkg.com/react-router/-/react-router-4.3.1.tgz#aada4aef14c809cb2e686b05cee4742234506c4e"
7169+
integrity sha512-yrvL8AogDh2X42Dt9iknk4wF4V8bWREPirFfS9gLU1huk6qK41sg7Z/1S81jjTrGHxa3B8R3J6xIkDAA6CVarg==
7170+
dependencies:
7171+
history "^4.7.2"
7172+
hoist-non-react-statics "^2.5.0"
7173+
invariant "^2.2.4"
7174+
loose-envify "^1.3.1"
7175+
path-to-regexp "^1.7.0"
7176+
prop-types "^15.6.1"
7177+
warning "^4.0.1"
7178+
71187179
react-test-renderer@16.3.1:
71197180
version "16.3.1"
71207181
resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.3.1.tgz#d9257936d8535bd40f57f3d5a84e7b0452fb17f2"
@@ -7430,6 +7491,11 @@ resolve-from@^3.0.0:
74307491
version "3.0.0"
74317492
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-3.0.0.tgz#b22c7af7d9d6881bc8b6e653335eebcb0a188748"
74327493

7494+
resolve-pathname@^2.2.0:
7495+
version "2.2.0"
7496+
resolved "https://registry.yarnpkg.com/resolve-pathname/-/resolve-pathname-2.2.0.tgz#7e9ae21ed815fd63ab189adeee64dc831eefa879"
7497+
integrity sha512-bAFz9ld18RzJfddgrO2e/0S2O81710++chRMUxHjXOYKF6jTAMrUNZrEZ1PvV0zlhfjidm08iRPdTLPno1FuRg==
7498+
74337499
resolve-url@^0.2.1:
74347500
version "0.2.1"
74357501
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
@@ -8499,6 +8565,11 @@ validate-npm-package-license@^3.0.1:
84998565
spdx-correct "^3.0.0"
85008566
spdx-expression-parse "^3.0.0"
85018567

8568+
value-equal@^0.4.0:
8569+
version "0.4.0"
8570+
resolved "https://registry.yarnpkg.com/value-equal/-/value-equal-0.4.0.tgz#c5bdd2f54ee093c04839d71ce2e4758a6890abc7"
8571+
integrity sha512-x+cYdNnaA3CxvMaTX0INdTCN8m8aF2uY9BvEqmxuYp8bL09cs/kWVQPVGcA35fMktdOsP69IgU7wFj/61dJHEw==
8572+
85028573
vary@~1.1.2:
85038574
version "1.1.2"
85048575
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
@@ -8533,6 +8604,20 @@ walker@~1.0.5:
85338604
dependencies:
85348605
makeerror "1.0.x"
85358606

8607+
warning@^3.0.0:
8608+
version "3.0.0"
8609+
resolved "https://registry.yarnpkg.com/warning/-/warning-3.0.0.tgz#32e5377cb572de4ab04753bdf8821c01ed605b7c"
8610+
integrity sha1-MuU3fLVy3kqwR1O9+IIcAe1gW3w=
8611+
dependencies:
8612+
loose-envify "^1.0.0"
8613+
8614+
warning@^4.0.1:
8615+
version "4.0.2"
8616+
resolved "https://registry.yarnpkg.com/warning/-/warning-4.0.2.tgz#aa6876480872116fa3e11d434b0d0d8d91e44607"
8617+
integrity sha512-wbTp09q/9C+jJn4KKJfJfoS6VleK/Dti0yqWSm6KMvJ4MRCXFQNapHuJXutJIrWV0Cf4AhTdeIe4qdKHR1+Hug==
8618+
dependencies:
8619+
loose-envify "^1.0.0"
8620+
85368621
watch@~0.18.0:
85378622
version "0.18.0"
85388623
resolved "https://registry.yarnpkg.com/watch/-/watch-0.18.0.tgz#28095476c6df7c90c963138990c0a5423eb4b986"

0 commit comments

Comments
 (0)