axios({
method: 'post',
url: `${ROOT_URL}/posts`,
data: {
},
headers: { authorization: localStorage.getItem("token") }
})
connect(mapStateToProps, null)(Authentication);
const { isLoaded, fetchData } = this.props;
if (!isLoaded) fetchData();
import React, {Component} from 'react';
import { connect } from "react-redux";
import { addData } from '../actions';
import Form from '../components/Form';
const mapDispatchToProps = {
addData,
};
export default connect(null, mapDispatchToProps)(Form);
.spinner{
height:140px;
width: 140px;
background: url('https://discuss-assets.s3.amazonaws.com/original/3X/0/3/03ad072969fc47ab98c776a60afc76d61e4877e8.svg') no-repeat;
background-position: 22px 30px;
background-size: 96px 96px;
animation: spin infinite .7s linear;
position: absolute;
top:0;
left:0;
right:0;
bottom:0;
margin:auto;
}
onChange = value => {
const [from, to] = value;
const filteredStudios = this.state.studios.filter(studio =>
studio.price >= from && studio.price <= to
);
this.setState({
studios: filteredStudios,
from,
to,
});
};
const mapStateToProps = state => {
return {
items: state.items.items,
error: state.items.error,
loading: state.items.loading
};
};
export function items(state = initialState, action) {
const { type, payload } = action;
switch (type) {
// some code
case "FETCH_SUCCESS":
return {
...state,
items: [ ...state.items, ...payload.items ],
loading: false,
};
// some code
}
}
export const fetchProductsBegin = () => ({ type: FETCH_BEGIN });
const mapStateToProps = state => ({
items: state.items.items,
error: state.items.error,
loading: state.items.loading,
});
return { ...state, year: action.payload }
это вернет вам {year:2017} и в компоненте уже к нему обращаться нужно вот так {year.year}{ tweets: tweets.data }
const reducer = (state = { tweets: tweets.data }, action) => {
switch (action.type) {
case 'DELETE': {
return {
...state,
tweets: state.tweets.filter(value => value.id !== action.id),
};
}
default:
return state;
}
};
var correctAnswers = $('.que .correct')
correctAnswers.each(function(index, element){
console.log($(element).text())
});
console.log("Верных ответов: " + correctAnswers.length)