export default {
name: "profile-account",
props: [
'url',
'amount'
],
mounted() {
},
data() {
return {
balance: this.amount,
isOpen: false
}
},
methods: {
showAddfunds: function(){
this.isOpen = !this.isOpen
console.log(this.isOpen)
}
}
}
В чем может быть причина?
const mapStateToProps = state => { // принимаем аргумент
return {
name: state && state.name, // используем аргумент
};
};
const mapStateToProps = state => ({
name: state && state.name,
});
const getColor = value => {
switch(value) {
case 20:
return 'orange';
case 50:
return 'blue';
}
}
render() {
const { value } = this.props;
return <ExampleComponent style={{ color: getColor(value) }} />;
}
const funcName = () = > dispatch => {
return dispatch({
type: NAME_TYPE,
payload: lol
});
}
Что значить dispatch в данном коде?
dispatch => {
return dispatch({
type: NAME_TYPE,
payload: lol
});
}
Почему мы его не передаем как аргумент в скобках?
const foo = (bar) => bar;
const foo = bar => bar;
const funcName = () = > ({
type: NAME_TYPE,
payload: lol,
});
export const endWorkingDay = () => (dispatch, getState) => {
return axios.post(`${API_ROOT}/api/Account/EndWork?date=${endDate}&tradePointId=${id}&lat=${currentLat}&long=${currentLong}`,
null,
{
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json;charset=UTF-8",
},
}
)
.then(
response => {
if (response.status === 200) {
dispatch({
type: SET_END_WORK_DATA,
payload: {
endWorkData: {
tradePointId: id,
lat: currentLat,
long: currentLong,
date: dateformat(new Date(), "yyyy-mm-dd"),
synced: true,
},
},
})