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, { Component } from 'react'; | |
// Must use connect() here because we have our App.js wrapped in a Provider. | |
// Once there's a change in the state, the Provider will re-render this component | |
// because it is a child of App.js | |
import { connect } from 'react-redux'; | |
//Below we are exporting the Tasks class so that we can call it in our | |
//connect(), method on the bottom. | |
export class Tasks extends Component { |
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, { Component } from "react"; | |
export default class UserInput extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { |
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 default function manageTasks(state = { | |
tasks: [], | |
}, action){ | |
switch (action.type) { | |
case 'ADD_TASK': | |
return Object.assign({}, state, { | |
tasks: state.tasks.concat(action.task) | |
}); |
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 App from './App'; | |
// Require the Provider library from react-redux below. | |
import { Provider } from 'react-redux'; | |
// createStore is replacing the manual createStore that we've created in the | |
// previous lab. | |
import { createStore } from 'redux'; |
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, { Component } from 'react'; | |
class Band extends Component { | |
// When we are handing the click, we would ideally want to change our current | |
// state to remove this item. We need to call our dispatch function and include a DELETE | |
// type so we can impliment logic later in our manageBand.js. | |
handleClick(e){ | |
e.preventDefault(); |
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, { Component } from 'react'; | |
class BandInput extends Component{ | |
constructor(){ | |
super(); | |
this.state={ | |
text: "" | |
} |
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, { Component } from 'react'; | |
import Band from './Band'; | |
class Bands extends Component { | |
render() { | |
const bands = this.props.store.getState().bands.map((band, index) => { | |
return <Band key={index} band={band} store={this.props.store} /> | |
}) | |
//See how we are passing in this.props.store |
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
// manageBand is our state manager for Bands. Basically, | |
// instead of making changes in component states, | |
// we're going to be taking care of those state changes here when it | |
// comes to Bands. | |
//counter is just for the unique ID for our Delete case. | |
let counter = 0 | |
export default function manageBand (state = { | |
bands: [] |
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, { Component } from 'react'; | |
import BandInput from './components/BandInput'; | |
import Bands from './components/Bands'; | |
class App extends Component{ | |
// We have to continue passing in the function store into children | |
// components. | |
render(){ | |
return( |
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 { renderer } from './index.js'; | |
export default function createStore(reducer) { | |
// We're defining a new variable called state where we | |
// are going to set to be equal to the state in our reducer | |
let state; | |
function dispatch(action) { |