未捕获的TypeError:无法读取属性' show'与React和Auth0的未定义错误

时间:2016-08-31 20:22:56

标签: authentication meteor reactjs auth0

我收到了Uncaught TypeError: Cannot read property 'show' of undefined with React and Auth0我无法调试的内容。

我已经关注 auth0 做出反应 tutorial,但仍无法让它发挥作用。

这是我的代码:

### login.jsx

/// <reference path="../../../typings/index.d.ts" />

import * as React from "react"

import Auth0Lock from 'auth0-lock'
import Button from './button.jsx'

export default class Login extends React.Component {


    componentDidMount() {
        this.lock = new Auth0Lock('AUTH0-CLIENT_ID', 'AUTH0_CLIENT_DOMAIN')`
    }
    render() {

        return (
            <div>
                Login Today
                <Button lock={this.lock}/>
            </div>
        )
    }
}



## button.jsx
/// <reference path="../../../typings/index.d.ts" />


import React from 'react'

export default class Button extends React.Component {
  constructor(props) {
    super(props)

    this.login = this.login.bind(this);
}

  login() {
    console.log(this.props.lock)
    this.props.lock.show(); 
  }

  render() {
    return (
        <button onClick={this.login}>Login with Auth</button>
    )
  }
}

0 个答案:

没有答案