Co2p Co2p - 1 year ago 80
React JSX Question

const arrow function can't access imports

Why is User not defined in the springboard function?

springboard is called

in a React router Route.

import User from '/imports/api/user.js';

const springboard = (nextState, replace, callback) => {

Snippet from User:

User = {
get: function() {
return Meteor.user() || {};

Answer Source

You have to export the object that you want to import:

export default {
  get: …

Note that the name of the exported object doesn't matter. You can give it any name, e.g., User when importing.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download