我正在尝试开始使用 Walamat 的电极反应应用程序框架,但不确定如何在应用程序挂载时添加行为。我想使用 auth0.lock 设置应用程序身份验证,并希望在应用程序componentDidMount
函数中实现对其进行初始化。
http://www.electrode.io/docs/whats_inside.html
如何将它添加到 app.jsx 文件中?那是正确的地方吗?window.webappStart 是否期望返回一个反应组件?
//
// This is the client side entry point for the React app.
//
import React from 'react';
import { render } from 'react-dom';
import { Router } from 'react-router';
import { createStore } from 'redux';
import { Provider } from 'react-redux';
import { routes } from './routes';
import rootReducer from './reducers';
import './styles/base.css';
//
// Add the client app start up code to a function as window.webappStart.
// The webapp's full HTML will check and call it once the js-content
// DOM is created.
//
window.webappStart = () => {
const initialState = window.__PRELOADED_STATE__;
const store = createStore(rootReducer, initialState);
render(
<Provider store={store}>
<Router>{routes}</Router>
</Provider>,
document.querySelector('.js-content')
);
};