Answer the question
In order to leave comments, you need to log in
Can't export object: React?
Good afternoon! I'm struggling with exporting an object and importing it in another file, but unfortunately nothing comes of it. Where did I make a mistake?
// Файл 1
export CONST = {
START_TIMER: 'start_timer',
FINISH_TIMER: 'finish_timer',
PAUSE_TIMER: 'pause_timer',
TICK_TIMER: 'tick_timer',
SKIP_TIMER: 'skip_timer',
FINISH_BREAK: 'finish_break',
TAKE_BREAK: 'take_break',
};
// Второй файл
import { CONST } from '../constants/TimerConstants';
const initialState = {
sessionTime: 0,
currentTime: 0,
status: 'default',
prevStatus: 'default'
}
export const timer = (state = initialState, action) => {
console.log(CONST);
switch (action.type) {
case CONST.START_TIMER:
return {
...state, sessionTime: action.data, currentTime: action.data, status: CONST.TICK_TIMER
}
case CONST.TICK_TIMER:
return {
...state, currentTime: state.currentTime - 1, status: action.type
}
case CONST.SKIP_TIMER:
return {
...initialState
}
case CONST.PAUSE_TIMER:
return {
...state, status: CONST.PAUSE_TIMER
}
case CONST.FINISH_TIMER:
return {
...state, currentTime: action.data, sessionTime: 0, status: CONST.FINISH_TIMER
}
case CONST.RESUME_TIMER:
return {
...state, status: CONST.TICK_TIMER
}
case CONST.TAKE_BREAK:
return {
...state, status: CONST.TICK_TIMER, prevStatus: CONST.AKE_BREAK
}
case CONST.FINISH_BREAK:
return {
...initialState
}
default:
return state;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question