我收到了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>
)
}
}