ReactJS: кнопка Intuit отображается при обновлении, но не при переходе с другой страницы
Я хотел бы показать кнопку Intuit ("Подключиться к Quickbooks") в компоненте, чтобы пользователи могли предоставить моему приложению доступ к Intuit Payments.
Когда я перемещаюсь с другой страницы в моем веб-приложении на страницу, на которой есть кнопка Quickbooks, кнопка отсутствует (как будто она не введена). Но когда я обновляю свою страницу, кнопка отображается, как и ожидалось.
Компонент QuickBooks: импорт React из 'реакции'; импорт firebase из 'firebase';
class QuickBooks extends React.Component {
constructor(props){
super(props);
// Note: I need the userID for my grant url
firebase.auth().onAuthStateChanged(function(user) {
console.log("user = " + user);
if (!user) {
console.log("no user logged in");
return
}
// set up intuit payments connect button
window.intuit.ipp.anywhere.setup({
grantUrl: <GRANT-URL>
datasources: {
quickbooks: false,
payments: true
}
});
}.bind(this))
}
componentDidMount() {
let buttonContainer = document.getElementById("intuButton")
const connectToIntuit = document.createElement('ipp:connectToIntuit');
buttonContainer.appendChild(connectToIntuit);
}
render(){
return (
<div id="intuButton"></div>
)
}
}
export default QuickBooks
Деятельность:
import React from 'react'
import QuickBooks from './QuickBooks'
class SomeActivity extends React.Component {
constructor(props){
super(props);
}
render(){
return (
<div>
<h1>Go on! Connect!</h1>
<QuickBooks/> //ISSUE: sometimes the button is shown on refresh, but not when this page is navigated to from another page
</div>
)
}
}
export default SomeActivity
Активность перемещается через this.props.history.push('/somePath')
,
Попытка исправить:
Осмотрев дальше, я вижу ipp
элемент вводится, но a
Элемента внутри него нет.
При обновлении (правильно):
<ipp:connecttointuit><a href="javascript:void(0)" class="intuitPlatformConnectButton">Connect with QuickBooks</a></ipp:connecttointuit>
В навигации (проблема, кнопка не отображается):
<ipp:connecttointuit></ipp:connecttointuit>
Кто-нибудь понимает, почему кнопка Intuit отображается при обновлении, а не при навигации с другой страницы?