Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 42 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/components/ChangeTemperature.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import React from "react";
import store from '../store';

function ChangeTemperature(props){
return(
<div>
<br/>
<label>Change Temp - Enter a value from 1-100<br/>
<input onChange={(e)=>{

let value = e.target.value;
let message = {
type: 'SET_TEMP',
value: value
}
store.dispatch(message);
}} type="number" min="0" max="100" />
</label>
</div>
Expand Down
8 changes: 7 additions & 1 deletion src/components/CityDropDown.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import React from 'react';
import store from '../store';

function CityDropDown(props) {
return (
<div>
CurrentCity:
<select onChange={
(e)=>{

let value = e.target.value;
let message = {
type: 'SET_CURRENT_CITY',
value: value
}
store.dispatch(message)
}
}>
<option value="Austin">Austin</option>
Expand Down
9 changes: 9 additions & 0 deletions src/components/Counter.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import React from 'react';
import store from '../store';

class Counter extends React.Component {

state={count:0}

componentDidMount() {
store.subscribe(() => {
let count = store.getState().currentCount;
this.setState({count})
})
}

render() {
const {
props,
Expand Down
11 changes: 9 additions & 2 deletions src/components/CounterButton.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import React from 'react';
import store from '../store';

function CounterButton(props) {
return (
<div>
<button onClick={
()=>{

let message = {
type: 'INCREASE_COUNTER'
};
store.dispatch(message);
}
}>Increase Counter By One</button>
<button onClick={
()=>{

let message = {
type: 'DECREASE_COUNTER'
}
store.dispatch(message);
}
}>Decrease Counter By One</button>
</div>
Expand Down
8 changes: 8 additions & 0 deletions src/components/CurrentCity.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import React from 'react';
import store from '../store';

class CurrentCity extends React.Component {
state={
text:""
}

componentDidMount() {
store.subscribe(() => {
let text = store.getState().currentCity;
this.setState({text});
})
}

render() {
const {
props,
Expand Down
18 changes: 16 additions & 2 deletions src/components/Modal.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
import React from 'react';
import Modal from 'react-modal';
import store from '../store';

class LoadingModal extends React.Component {
state={
isLoading:false
}

componentDidMount() {
store.subscribe(() => {
console.log(store.getState().isLoading);
let isLoading = store.getState().isLoading;
this.setState({isLoading: isLoading});
})
}

render() {
const {
props,
} = this;

return (
<Modal
isOpen={props.isLoading}
isOpen={this.state.isLoading}
style={customStyles}
contentLabel="Example Modal"
>
<button onClick={
()=>{

let message = {
type: 'SET_IS_LOADING',
value: false
}
store.dispatch(message)
}
}>close</button>
<div>Loading .......</div>
Expand Down
9 changes: 8 additions & 1 deletion src/components/ShowModal.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import React from 'react';
import store from '../store';
import state from '../state';

function ShowModal(props) {

return (
<div>
<button onClick={
()=>{

let message = {
type: 'SET_IS_LOADING',
value: true
}
store.dispatch(message);
}
}>Show Modal</button>

Expand Down
Loading