This file contains 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 { createStore, compose, applyMiddleware } from 'redux'; | |
import thunk from 'redux-thunk'; | |
import reducers from './reducers'; | |
const composeEnhancer = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; | |
const store = createStore( | |
reducers, | |
composeEnhancer(applyMiddleware(thunk)), | |
); |
This file contains 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 { combineReducers } from 'redux' | |
import profile from './profile' | |
export default combineReducers({ | |
profile, | |
}) |
This file contains 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 { | |
EMAIL_CHANGED | |
} from '../actions/profile'; | |
const INITIAL_STATE = { | |
email: 'test@redux.com' | |
} | |
const profileReducer = (state = INITIAL_STATE, action) => { | |
switch (action.type) { |
This file contains 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 EMAIL_CHANGED = 'email_changed'; | |
export const changeEmail = (email) => ({ | |
type: EMAIL_CHANGED, | |
}) |
This file contains 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 '../App.css'; | |
import {connect} from "react-redux"; | |
import { bindActionCreators } from 'redux'; | |
import { changeEmail } from '../actions'; | |
const Home = ({email, changeEmail}) => { | |
return ( | |
<div className="App"> | |
<header className="App-header"> |
This file contains 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
git branch | grep -v "master\|develop" | xargs git branch -D |
This file contains 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
git branch | grep -v "master\|develop" | xargs git branch -D |
This file contains 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, { useState } from "react"; | |
import ReactDOM from "react-dom"; | |
const AppWithHooks = () => { | |
// count = state | |
// setCount = setState | |
// 0 = initial count state value | |
const [count, setCount] = useState(0); | |
return ( |
This file contains 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
class AppWithClass extends React.Component{ | |
constructor(props){ | |
super(props) | |
this.state={ | |
count: 0, | |
} | |
} | |
render(){ | |
const {count} = this.state; | |
return( |
This file contains 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
const AppWithHooks = () => { | |
const [count, setCount] = useState(0); | |
const [name, setName] = useState('Hadnazzar'); | |
return ( | |
<div className="App"> | |
<h1>Hello React with Hooks</h1> | |
<h2>You clicked {count} times!</h2> | |
<h2>Hello {name}</h2> | |
<button onClick={() => setCount(count - 1)}>Decrement</button> |