<a href={this.props.serials.image.medium}>photo</a>
$r.props.serials.image.medium
все показывает => "http://static.tvmaze.com/uploads/images/medium_portrait/128/322443.jpg"
export function addProduct(product){
console.log('dispatching add product');
return {
type: ADD_PRODUCT,
product
};
}
case ADD_PRODUCT:
return {
...state,
products: state.products.concat(action.product)
};
//load file
const initialState = { products: [] };
export default function productReducer (state = initialState,action) {
console.log('this state is changed');
console.log(state,action);
switch (action.type) {
case "FETCH_PRODUCTS":
return{
...state,
products: action.products
};
//add
case ADD_PRODUCT:
return{
...state,
products: [...state.products, action.product]
};
default:
return state;
}
}
import React from "react";
export default function ProductList({products}){
const list = () => {
if(products){
return products.map(product => {
return (
<li key={product.id}>{product.title}</li>
)
})
}else{
return []
}
};
import { combineReducers } from 'redux';
import ProductReducer from "./product_reducer";
import { localeReducer } from 'react-localize-redux';
const rootReducer = combineReducers({
productReducer: ProductReducer
});
export default rootReducer;