import React from "react";
import { connect } from "react-redux";
import { actionGreen, actionRed } from "../../actions/counter";
const Counter = ({ actionRed,actionGreen, state }) => {
return (
<div>
<button onClick={actionRed} style={{backgroundColor: state}}>Red</button>
<button onClick={actionGreen} style={{backgroundColor: state}}>Green</button>
</div>
);
}
const mapStateToProps = (state) => ({state });
const mapDispatchToProps = {
actionRed,
actionGreen
};
export const CounterContainer = connect(mapStateToProps, mapDispatchToProps)(Counter);
=========
const initialColor ={
background: 'white'
}
const initialRed ={
background: 'red'
}
const initialGreen ={
background: 'green'
}
export const counterReducer = (state=initialColor.background, action) => {
switch(action.type) {
case "RED": {
return {
state:initialRed.background
};
}
case "GREEN": {
return {
state:initialGreen.background
}
}
default: {
return state;
}
}
};
dataa && l.userId === dataa.id
const deleteUser = () => {
axios.get(`http://localhost:3001/users/${user.id}`)
.then(({ data }) => {
const userData = data
console.log(userData)
axios.get(`http://localhost:3001/lists`)
.then(({ data }) => {
data.map(l => {
if(userData && l.userId === userData.id){
console.log(l)
}
})
})
})
.catch(e => {
alert('Ошибка');
})
}
Тут вам не angular, реакт не предоставляет специфичных методов для работы с преобразованием данных.