G
G
Grigory Dikiy2016-08-19 19:44:23
JavaScript
Grigory Dikiy, 2016-08-19 19:44:23

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;
  }
}

Console.log() outputs undefined.
PS: I'm using React + Electron. Grateful for help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2016-08-19
@frilix

You need:
export const (or let, function, class ...) NAME, and you just have export NAME. Hence the problem.
For example:
and in another file:
import { NOTIFICATION_SHOW } from 'bla/bla/bla'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question