Skip to content

Commit

Permalink
simplify the app
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Meyer authored and bnek committed Sep 17, 2020
1 parent c5d411f commit 7eab6bc
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import React, { Component } from 'react';
import { Route } from 'react-router';
import { Layout } from './components/Layout';
import { Home } from './components/Home';
import { FetchData } from './components/FetchData';
import { Counter } from './components/Counter';

import './custom.css'

Expand All @@ -14,8 +12,6 @@ export default class App extends Component {
return (
<Layout>
<Route exact path='/' component={Home} />
<Route path='/counter' component={Counter} />
<Route path='/fetch-data' component={FetchData} />
</Layout>
);
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
import React, { Component } from 'react';

export class Home extends Component {
static displayName = Home.name;
constructor(props) {
super(props);
this.state = {};
}

fetchWeather() {
fetch("/weatherforecast").then(response => {
response.json().then(result => {
this.setState(result);
})
});
}

render () {
render() {
const weather = this.state && this.state[0] ? this.state[0] : undefined;
return (
<div>
<h1>Hello, world!</h1>
<p>Welcome to your new single-page application, built with:</p>
<ul>
<li><a href='https://get.asp.net/'>ASP.NET Core</a> and <a href='https://msdn.microsoft.com/en-us/library/67ef8sbd.aspx'>C#</a> for cross-platform server-side code</li>
<li><a href='https://facebook.github.io/react/'>React</a> for client-side code</li>
<li><a href='http://getbootstrap.com/'>Bootstrap</a> for layout and styling</li>
</ul>
<p>To help you get started, we have also set up:</p>
<ul>
<li><strong>Client-side navigation</strong>. For example, click <em>Counter</em> then <em>Back</em> to return here.</li>
<li><strong>Development server integration</strong>. In development mode, the development server from <code>create-react-app</code> runs in the background automatically, so your client-side resources are dynamically built on demand and the page refreshes when you modify any file.</li>
<li><strong>Efficient production builds</strong>. In production mode, development-time features are disabled, and your <code>dotnet publish</code> configuration produces minified, efficiently bundled JavaScript files.</li>
</ul>
<p>The <code>ClientApp</code> subdirectory is a standard React application based on the <code>create-react-app</code> template. If you open a command prompt in that directory, you can run <code>npm</code> commands such as <code>npm test</code> or <code>npm install</code>.</p>
<h1>Tomorrow's weather forecast</h1>
<br />
<button onClick={() => this.fetchWeather() }>refresh</button>
<br />
{weather &&
<div>
<p>Temperature: {weather.temperatureC}</p>
<p>Sumnmary: {weather.summary}</p>
</div>
}
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ export class NavMenu extends Component {
<NavItem>
<NavLink tag={Link} className="text-dark" to="/">Home</NavLink>
</NavItem>
<NavItem>
<NavLink tag={Link} className="text-dark" to="/counter">Counter</NavLink>
</NavItem>
<NavItem>
<NavLink tag={Link} className="text-dark" to="/fetch-data">Fetch data</NavLink>
</NavItem>
</ul>
</Collapse>
</Container>
Expand Down

0 comments on commit 7eab6bc

Please sign in to comment.