Skip to content

Instantly share code, notes, and snippets.

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>
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 {
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 {
//TaskAction.js
//We are packaging the data for the reducer.
export const addTask = (task) => {
return {
type: 'ADD_TASK',
task
};
};
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) {
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';
import React from 'react';
class Todo extends React.Component{
constructor(){
super();
this.state={
complete: false
}
import React from 'react';
class Todo extends React.Component{
constructor(){
super();
this.state={
complete: false
}
import React from 'react';
class Todo extends React.Component{
constructor(){
super();
this.state={
complete: false
}
componentWillReceiveProps(nextProps){
console.log('d')
if(nextProps !== this.props){
this.setState({
complete: false
})
}
}
shouldComponentUpdate(nextProps, nextState){