onBackPress = () => {
const { dispatch, nav } = this.props
if (nav.index === 0) {
return false
}
dispatch(NavigationActions.back())
return true
}
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,
},
},
})
componentWillReceiveProps(nextProps) {
console.log("nextProps.idcat",nextProps.idcat)
if (nextProps.idcat!==undefined){
fetch(`${ENV.API_PROT}${ENV.API_LINK}/api/${ENV.API_VER_GLOBAL}/categories/${nextProps.idcat}`)
.then(response => response.json())
.then(json => {
console.log(json);
this.setState({
sameNews: json.data,
isLoading: false
});
console.log(this.state.sameNews);
});
}
}
@melkaya94, <code lang="javascript">
async handleOnClick(i){
await this.setState({
selectCard: {
...this.state.selectCard,
[i]: !this.state.selectCard[i]
}
},() => {this.amountSelectSwatches(this.state.selectCard,i)}); // вызов счетчика
}
amountSelectSwatches(obj,ind){
if(obj[ind]===true){
await this.setState({
count:Object.assign({},this.state.count,{[ind]:++this.state.count[ind]})
})
}}
</code>
если вам это не нравится вы можете использовать глобальную переменную для хранения count
axios({
method: 'post',
url: `${ROOT_URL}/posts`,
data: {
},
headers: { authorization: localStorage.getItem("token") }
})