From 8f40816233d65e8db6a98f61916deb5c0536db5a Mon Sep 17 00:00:00 2001 From: Brandon Everett Date: Tue, 7 Mar 2017 07:39:45 -0500 Subject: [PATCH 1/2] remove isomorphic-fetch import in FetchData --- .../ClientApp/components/FetchData.tsx | 125 +++++++++--------- 1 file changed, 62 insertions(+), 63 deletions(-) diff --git a/templates/ReactSpa/ClientApp/components/FetchData.tsx b/templates/ReactSpa/ClientApp/components/FetchData.tsx index e76625bd..13e1c782 100644 --- a/templates/ReactSpa/ClientApp/components/FetchData.tsx +++ b/templates/ReactSpa/ClientApp/components/FetchData.tsx @@ -1,63 +1,62 @@ -import * as React from 'react'; -import 'isomorphic-fetch'; - -interface FetchDataExampleState { - forecasts: WeatherForecast[]; - loading: boolean; -} - -export class FetchData extends React.Component { - constructor() { - super(); - this.state = { forecasts: [], loading: true }; - - fetch('/api/SampleData/WeatherForecasts') - .then(response => response.json() as Promise) - .then(data => { - this.setState({ forecasts: data, loading: false }); - }); - } - - public render() { - let contents = this.state.loading - ?

Loading...

- : FetchData.renderForecastsTable(this.state.forecasts); - - return
-

Weather forecast

-

This component demonstrates fetching data from the server.

- { contents } -

For more sophisticated applications, consider an architecture such as Redux or Flux for managing state. You can generate an ASP.NET Core application with React and Redux using dotnet new aspnet/spa/reactredux instead of using this template.

-
; - } - - private static renderForecastsTable(forecasts: WeatherForecast[]) { - return - - - - - - - - - - {forecasts.map(forecast => - - - - - - - )} - -
DateTemp. (C)Temp. (F)Summary
{ forecast.dateFormatted }{ forecast.temperatureC }{ forecast.temperatureF }{ forecast.summary }
; - } -} - -interface WeatherForecast { - dateFormatted: string; - temperatureC: number; - temperatureF: number; - summary: string; -} +import * as React from 'react'; + +interface FetchDataExampleState { + forecasts: WeatherForecast[]; + loading: boolean; +} + +export class FetchData extends React.Component { + constructor() { + super(); + this.state = { forecasts: [], loading: true }; + + fetch('/api/SampleData/WeatherForecasts') + .then(response => response.json() as Promise) + .then(data => { + this.setState({ forecasts: data, loading: false }); + }); + } + + public render() { + let contents = this.state.loading + ?

Loading...

+ : FetchData.renderForecastsTable(this.state.forecasts); + + return
+

Weather forecast

+

This component demonstrates fetching data from the server.

+ { contents } +

For more sophisticated applications, consider an architecture such as Redux or Flux for managing state. You can generate an ASP.NET Core application with React and Redux using dotnet new aspnet/spa/reactredux instead of using this template.

+
; + } + + private static renderForecastsTable(forecasts: WeatherForecast[]) { + return + + + + + + + + + + {forecasts.map(forecast => + + + + + + + )} + +
DateTemp. (C)Temp. (F)Summary
{ forecast.dateFormatted }{ forecast.temperatureC }{ forecast.temperatureF }{ forecast.summary }
; + } +} + +interface WeatherForecast { + dateFormatted: string; + temperatureC: number; + temperatureF: number; + summary: string; +} From 8eadfe3afdccceaecbe7fdc99b8a4b5af9f0e302 Mon Sep 17 00:00:00 2001 From: Brandon Everett Date: Tue, 7 Mar 2017 07:46:30 -0500 Subject: [PATCH 2/2] update line endings --- .../ClientApp/components/FetchData.tsx | 124 +++++++++--------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/templates/ReactSpa/ClientApp/components/FetchData.tsx b/templates/ReactSpa/ClientApp/components/FetchData.tsx index 13e1c782..0db6c070 100644 --- a/templates/ReactSpa/ClientApp/components/FetchData.tsx +++ b/templates/ReactSpa/ClientApp/components/FetchData.tsx @@ -1,62 +1,62 @@ -import * as React from 'react'; - -interface FetchDataExampleState { - forecasts: WeatherForecast[]; - loading: boolean; -} - -export class FetchData extends React.Component { - constructor() { - super(); - this.state = { forecasts: [], loading: true }; - - fetch('/api/SampleData/WeatherForecasts') - .then(response => response.json() as Promise) - .then(data => { - this.setState({ forecasts: data, loading: false }); - }); - } - - public render() { - let contents = this.state.loading - ?

Loading...

- : FetchData.renderForecastsTable(this.state.forecasts); - - return
-

Weather forecast

-

This component demonstrates fetching data from the server.

- { contents } -

For more sophisticated applications, consider an architecture such as Redux or Flux for managing state. You can generate an ASP.NET Core application with React and Redux using dotnet new aspnet/spa/reactredux instead of using this template.

-
; - } - - private static renderForecastsTable(forecasts: WeatherForecast[]) { - return - - - - - - - - - - {forecasts.map(forecast => - - - - - - - )} - -
DateTemp. (C)Temp. (F)Summary
{ forecast.dateFormatted }{ forecast.temperatureC }{ forecast.temperatureF }{ forecast.summary }
; - } -} - -interface WeatherForecast { - dateFormatted: string; - temperatureC: number; - temperatureF: number; - summary: string; -} +import * as React from 'react'; + +interface FetchDataExampleState { + forecasts: WeatherForecast[]; + loading: boolean; +} + +export class FetchData extends React.Component { + constructor() { + super(); + this.state = { forecasts: [], loading: true }; + + fetch('/api/SampleData/WeatherForecasts') + .then(response => response.json() as Promise) + .then(data => { + this.setState({ forecasts: data, loading: false }); + }); + } + + public render() { + let contents = this.state.loading + ?

Loading...

+ : FetchData.renderForecastsTable(this.state.forecasts); + + return
+

Weather forecast

+

This component demonstrates fetching data from the server.

+ { contents } +

For more sophisticated applications, consider an architecture such as Redux or Flux for managing state. You can generate an ASP.NET Core application with React and Redux using dotnet new aspnet/spa/reactredux instead of using this template.

+
; + } + + private static renderForecastsTable(forecasts: WeatherForecast[]) { + return + + + + + + + + + + {forecasts.map(forecast => + + + + + + + )} + +
DateTemp. (C)Temp. (F)Summary
{ forecast.dateFormatted }{ forecast.temperatureC }{ forecast.temperatureF }{ forecast.summary }
; + } +} + +interface WeatherForecast { + dateFormatted: string; + temperatureC: number; + temperatureF: number; + summary: string; +}