如何在Walmart电极反应应用程序中实现componentWillMount?

时间:2016-11-27 00:15:24

标签: reactjs walmart-electrode

我试图开始使用Walamart的电极反应应用程序框架,并且不确定如何在应用程序安装时添加行为。我想使用auth0.lock设置应用认证,并希望在应用componentDidMount功能中实现初始化。

http://www.electrode.io/docs/whats_inside.html

如何将其添加到app.jsx文件中?这是正确的地方吗? window.webappStart是否期望返回react组件?

//
// 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')
  );
};

0 个答案:

没有答案