сlick(e, index) {
this.setState(prevState => ({
array: prevState.array.filter((_, i) => i !== index),
}));
}
сlick(e, index) {
console.log(index);
}
render() {
const { array } = this.state;
const unit = array.map((item, index) => (
<a
key={index}
style={{display:"block"}}
onClick={(e) => this.click(e, index)}
>
Hello, {item}
</a>
));
import { FETCH_MENU, RECIEVE_MENU, FETCH_MENU_ERROR } from '../actions/mainMenu'
const defaultState = {
items: [],
fetching: false,
fetched: false,
};
export default function (state = defaultState, action) {
const { type, payload } = action;
switch(type) {
case FETCH_MENU:
return {
...state,
fetching: true,
fetched: false
};
case RECIEVE_MENU:
return {
...state,
fetching: false,
fetched: true,
items: payload.items
};
case FETCH_MENU_ERROR:
return {
...state,
fetching: false,
err: payload.err
};
default:
return state;
}
}
emailValidation = value => {
isValidEmail(value).then(val => this.setState({ isEmailValid: val })):
};
function getClassName() {
if (A && !B) {
return 'variant1';
} else if (!A && B) {
return 'variant2';
} else {
return 'variant3';
}
}
render () {
const classes = classNames({
'variant-1': A && !B,
'variant-2': !A && B,
'variant-3': !A && !B,
});
return <Example className={classes}></Example>;
}
/actions
/constrants
/reducers
/components
/containers
/lig
/blablabla
/common
/components
Button.js
Select.js
Row.js
/ducks
/utils
/styles
selectors.js
constrains.js
/features
/Filter
Filter.js
FilterContainer.js
filterDucks.js
filterSelectors.js
index.js
/ProductList.js
/components
Product.js
index.js
ProductList.js
ProductListContainer.js
productListDucks.js
productListSelectors.js
index.js
/pages
Products.js
App.js
index.js
rootReducer.js
routes.js
store.js