I have two files: User.js
and Login.js
. After login is successfull i want to call static logIn
method of User class. I have strange behaviour. What am I doing wrong?
File contents User.js:
// user/User.js
// I also tried export default class User
export class User {
static logIn (token) {
}
static logOut (token) {
}
static isAuthorized () {
}
}
And Login.js:
// login/Login.js
import React from 'react';
import GoogleLogin from 'react-google-login';
// I also tried import User from './../user/User';
// I also tried import {User} from './../user/User';
import * as User from './../user/User';
class Login extends React.Component {
constructor (props, context) {
super(props, context);
}
responseSuccess (googleUser) {
const idToken = googleUser.getAuthResponse().id_token;
User.logIn(idToken);
}
///
}
export default Login;
When I use import and export this way I get this behaviour:
So, User is an object with property User
. This property contains all methods of class User.
Is it possible to somehow export/import class so I will get user class methods in User
object?
Now there is only one way to use methods: User.User.logIn()
.