diff options
| author | Kamran Ahmed <kamranahmed.se@gmail.com> | 2018-08-19 14:23:27 +0400 |
|---|---|---|
| committer | Kamran Ahmed <kamranahmed.se@gmail.com> | 2018-08-19 14:23:27 +0400 |
| commit | 5c7e6dd54e90708e1be7ef540b06ad08e3d82ace (patch) | |
| tree | e1df36af400e1c7e6e4fc47f0f55d268956a602a /src | |
| parent | Update favicon and add home (diff) | |
| download | githunt-5c7e6dd54e90708e1be7ef540b06ad08e3d82ace.tar.gz | |
Restructure and add router
Diffstat (limited to 'src')
| -rw-r--r-- | src/App.js | 19 | ||||
| -rw-r--r-- | src/app.js | 12 | ||||
| -rw-r--r-- | src/containers/FeedContainer.js | 11 | ||||
| -rw-r--r-- | src/containers/OptionsContainer.js | 11 | ||||
| -rw-r--r-- | src/global.css (renamed from src/App.css) | 0 | ||||
| -rw-r--r-- | src/index.css | 2 | ||||
| -rw-r--r-- | src/index.js | 6 | ||||
| -rw-r--r-- | src/router/index.js | 19 | ||||
| -rw-r--r-- | src/worker.js (renamed from src/registerServiceWorker.js) | 14 |
9 files changed, 63 insertions, 31 deletions
diff --git a/src/App.js b/src/App.js deleted file mode 100644 index 0a93940..0000000 --- a/src/App.js +++ /dev/null @@ -1,19 +0,0 @@ -import React, { Component } from 'react'; -import './App.css'; - -class App extends Component { - render() { - return ( - <div className="App"> - <header className="App-header"> - <h1 className="App-title">Welcome to React</h1> - </header> - <p className="App-intro"> - To get started, edit <code>src/App.js</code> and save to reload. - </p> - </div> - ); - } -} - -export default App; diff --git a/src/app.js b/src/app.js new file mode 100644 index 0000000..83bbe84 --- /dev/null +++ b/src/app.js @@ -0,0 +1,12 @@ +import React, { Component } from 'react'; +import AppRoutes from './router'; + +class App extends Component { + render() { + return ( + <AppRoutes/> + ); + } +} + +export default App; diff --git a/src/containers/FeedContainer.js b/src/containers/FeedContainer.js new file mode 100644 index 0000000..5e42c08 --- /dev/null +++ b/src/containers/FeedContainer.js @@ -0,0 +1,11 @@ +import React from 'react'; + +class FeedContainer extends React.Component { + render() { + return ( + <h1>Hello from the feed</h1> + ); + } +} + +export default FeedContainer; diff --git a/src/containers/OptionsContainer.js b/src/containers/OptionsContainer.js new file mode 100644 index 0000000..172bd61 --- /dev/null +++ b/src/containers/OptionsContainer.js @@ -0,0 +1,11 @@ +import React from 'react'; + +class OptionsContainer extends React.Component { + render() { + return ( + <h1>Hello from the options</h1> + ); + } +} + +export default OptionsContainer; diff --git a/src/App.css b/src/global.css index e69de29..e69de29 100644 --- a/src/App.css +++ b/src/global.css diff --git a/src/index.css b/src/index.css deleted file mode 100644 index 139597f..0000000 --- a/src/index.css +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/index.js b/src/index.js index 40d071e..930791d 100644 --- a/src/index.js +++ b/src/index.js @@ -2,9 +2,9 @@ import React from 'react'; import ReactDOM from 'react-dom'; import 'bootstrap/dist/css/bootstrap.css'; -import './index.css'; -import App from './App'; -import registerServiceWorker from './registerServiceWorker'; +import './global.css'; +import App from './app'; +import registerServiceWorker from './worker'; ReactDOM.render(<App/>, document.getElementById('root')); registerServiceWorker(); diff --git a/src/router/index.js b/src/router/index.js new file mode 100644 index 0000000..8bc4254 --- /dev/null +++ b/src/router/index.js @@ -0,0 +1,19 @@ +import React from 'react'; +import { BrowserRouter, Route, Switch } from 'react-router-dom'; + +import FeedContainer from '../containers/FeedContainer'; +import OptionsContainer from '../containers/OptionsContainer'; + +const AppRoutes = () => { + return ( + <BrowserRouter> + <Switch> + <Route exact path='/' component={ FeedContainer }/> + <Route exact path='/options' component={ OptionsContainer }/> + <Route component={ FeedContainer }/> + </Switch> + </BrowserRouter> + ); +}; + +export default AppRoutes; diff --git a/src/registerServiceWorker.js b/src/worker.js index a3e6c0c..aadadb5 100644 --- a/src/registerServiceWorker.js +++ b/src/worker.js @@ -10,12 +10,12 @@ const isLocalhost = Boolean( window.location.hostname === 'localhost' || - // [::1] is the IPv6 localhost address. - window.location.hostname === '[::1]' || - // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) + // [::1] is the IPv6 localhost address. + window.location.hostname === '[::1]' || + // 127.0.0.1/8 is considered localhost for IPv4. + window.location.hostname.match( + /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ + ) ); export default function register() { @@ -41,7 +41,7 @@ export default function register() { navigator.serviceWorker.ready.then(() => { console.log( 'This web app is being served cache-first by a service ' + - 'worker. To learn more, visit https://goo.gl/SC7cgQ' + 'worker. To learn more, visit https://goo.gl/SC7cgQ' ); }); } else { |
