N
N
nuclear_kote2017-03-20 21:04:25
React
nuclear_kote, 2017-03-20 21:04:25

Why are constants not imported?

constants.js:

'use strict';

export const Constants =  {
  REST_URL: "https://example.com/"
};

app.js:
'use strict';

import React, { Component } from 'react';
import Constants from './Constants';

export default class App extends React.Component {

  constructor(props) {
    super(props);
    console.warn(Constants)  // undefined
    console.warn(JSON.stringify(Constants));
  }
    ...
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2017-03-20
@nuclear_kote

Because you made a named export, so you need to include:
import { Constants } from './Constants';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question