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 dayOfWeekSwitch = (nmb) => { | |
switch(nmb) { | |
case(0): { | |
return 'Monday' | |
} | |
case(1): return 'Tuesday' | |
case(2): return 'Wednesday' | |
default: return 'Makaka' | |
} | |
} |
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 initialState = { | |
name: 'ovasylenko' | |
} | |
export default (state = initialState, action) => { | |
switch (action.type) { | |
default: | |
return state | |
} | |
} |
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, applyMiddleware, compose } from 'redux' | |
import { composeWithDevTools } from 'redux-devtools-extension' | |
import thunk from 'redux-thunk' | |
import createRootReducer from './reducers' | |
const middleware = [thunk] | |
const initialState = {} | |
const composeFunc = process.env.NODE_ENV === 'development' ? composeWithDevTools : compose | |
const composedEnchanters = composeFunc(applyMiddleware(...middleware)) |
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 users from './users' | |
const createRootReducer = () => | |
combineReducers({ | |
users | |
}) | |
export default createRootReducer |
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 UPDATE_USER_NAME = 'UPDATE_USER_NAME' | |
const initialState = { | |
username: 'ovas' | |
} | |
export default (state = initialState, action) => { | |
switch (action,type) { | |
case UPDATE_USER_NAME: | |
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
export function setRepositories(username) { | |
return function (dispatch) { | |
fetch(`https://ap.github.com/users/${username}/repos`) | |
.then((r) => r.json()) | |
.then((list) => { | |
dispatch({ type: SET_REPOSITORIES, list }) | |
}) | |
} | |
} |
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
in server.js | |
const user = new User({ | |
email: 'test@gmail.com', | |
password: 'abracadabra' | |
}) | |
user.save() |
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 axios from 'axios' | |
import { useParams } from 'react-router-dom | |
const Category = () => { | |
const {category} = useParams() | |
const [value, setValue] = useState('') | |
const onChange = (event) => { |
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, useEffect } from 'react' | |
import axios from 'axios' | |
const User = () => { | |
const [user, setUser] = useState({}) | |
useEffect(() => { | |
axios.get('https://jsonplaceholder.typicode.com/users/1').then(it => { | |
setUser(it.data) | |
}) |
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
let oldArray = ['saha','dasha','manya'] | |
let newArray = | |
oldArray.map(name => `<div>${name}</div>`) |
OlderNewer