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 { connect } from 'react-redux'; | |
| class Tasks extends Component { | |
| render() { | |
| const tasks = this.props.tasks.map((task, index) => <li key={index}>{task}</li>) | |
| return ( | |
| <div> | |
| <ul> |
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 UserInput from "./components/UserInput"; | |
| // We change the below from { AllTasks } to Tasks because we are | |
| // exporting with default meaning there are no libraries that we are | |
| // pulling from. Just the class Tasks. | |
| import Tasks from './components/Tasks'; | |
| class App 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"; | |
| // we are new requiring connect. Essentially, it allows our component to have | |
| // access to the state and have the ability to manipulate the information using | |
| // an outside function. | |
| import { connect } from 'react-redux'; | |
| // Taking away export from this class. | |
| class UserInput 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
| //TaskAction.js | |
| //We are packaging the data for the reducer. | |
| export const addTask = (task) => { | |
| return { | |
| type: 'ADD_TASK', | |
| 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, { Component } from "react"; | |
| import { connect } from 'react-redux'; | |
| //Add the Code below to add the action addTask. | |
| import { addTask } from '../actions/TaskAction'; | |
| class UserInput extends Component { | |
| constructor(props) { |
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 { connect } from 'react-redux'; | |
| import { addTask } from '../actions/TaskAction'; | |
| // Using bindActionCreators allows us make a dispatch just from using an action. | |
| // Similar to binding a variable to an object. | |
| import { bindActionCreators } 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 from 'react'; | |
| class Todo extends React.Component{ | |
| constructor(){ | |
| super(); | |
| this.state={ | |
| complete: false | |
| } |
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'; | |
| class Todo extends React.Component{ | |
| constructor(){ | |
| super(); | |
| this.state={ | |
| complete: false | |
| } |
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'; | |
| class Todo extends React.Component{ | |
| constructor(){ | |
| super(); | |
| this.state={ | |
| complete: false | |
| } |
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
| componentWillReceiveProps(nextProps){ | |
| console.log('d') | |
| if(nextProps !== this.props){ | |
| this.setState({ | |
| complete: false | |
| }) | |
| } | |
| } | |
| shouldComponentUpdate(nextProps, nextState){ |