This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import './index.css'; | |
import App from './App'; | |
import Header from "./Components/Header"; | |
import 'bootstrap/dist/css/bootstrap.min.css'; | |
ReactDOM.render( | |
<React.StrictMode> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | |
# dependencies | |
/node_modules | |
/.pnp | |
.pnp.js | |
# testing | |
/coverage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// imports | |
class WeatherForm extends Component { | |
// default state values | |
// componentDidMount() | |
// refreshSaveWeather() | |
// onChange() | |
// saveFormData() | |
// saveToLocalStorage() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// imports | |
const path = require('path'); | |
// use body parser to get data from POST requests | |
// Use API routes from the api folder | |
// If in production, then use static frontend build files. | |
if (process.env.NODE_ENV === 'production') { | |
// Serve any static files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "mern-weather-app", | |
"scripts": { | |
"dev": "concurrently --kill-others-on-fail \"npm run server\" \"npm run client\"", | |
"heroku-postbuild": "cd client/src && npm install && npm run build" | |
}, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// imports | |
import {connect} from "react-redux"; | |
import {saveZipCode, saveWeatherData, saveTemperature, updateHistory} from "../actions"; | |
class WeatherForm extends Component { | |
// default state values | |
// componentDidMount() | |
refreshSavedWeather = () => { | |
if (localStorage.getItem("zipCode")) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// other imports | |
... | |
// Adding redux and reducers | |
import { createStore } from 'redux' | |
import { Provider } from 'react-redux' | |
import rootReducer from './reducers' | |
// Creates our store to use our reducers and the chrome extension to debug the redux store | |
const store = createStore( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get initial state from the previously saved data in local storage | |
let getHistoryFromLocal = () => { | |
let value = localStorage.getItem('WeatherHistory') | |
return JSON.parse(value) || []; | |
} | |
// Maintain a history list of queried weather data of 10 | |
let getUpdatedHistory = (history, value) => { | |
let updateList = [...history]; | |
if (updateList.length >= 10) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const saveZipCode = (zipCode) => { | |
return { | |
type: "SAVE_ZIP", | |
payload: zipCode | |
} | |
} | |
export const saveWeatherData = (data) => { | |
return { | |
type: "SAVE_WEATHER_DATA", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// other imports | |
import axios from 'axios'; | |
class WeatherForm extends Component { | |
// default state values | |
componentDidMount() { | |
this.refreshSavedWeather(); | |
} |
NewerOlder