Foundation 6 JS + React并不总是有效

时间:2017-07-24 11:51:29

标签: reactjs zurb-foundation zurb-foundation-6

我认为基础6.4.1和React存在问题。 我的环境配置如下所述:Foundation 6 + webpack : Cannot make Foundation JS work

我添加了$(document).foundation();我index.js方法中的componentDidMount内部(我已经在文件的顶部进行了测试,但它无法正常工作)

componentDidMount() {
   $(document).foundation();
}

所以使用这种配置基本上它正在工作,但在一些路由转换后它停止工作。在我的情况下,我正在从应用程序注销并重新连接)

在哪里使用$(document).foundation();命令让基础工作正常?

编辑: 我的index.js

/** @flow */
import 'babel-polyfill'

import 'script!jquery'
import 'script!what-input'
import 'foundation-sites/dist/js/foundation.js'

import React from 'react'
import moment from 'moment'
...


const store = createStore()

class App extends React.Component {
  state = {
    initialized: false,
  }

  async componentDidMount() {
    try {
      await store.dispatch(startLoggingInFromCookies())
      this.setState({ initialized: true })
    } catch (err) {
      console.warn(err)
    }

    $(document).foundation();
  }

  render() {
    if (!this.state.initialized) {
      return <Loader/>
    }

    return (
      <ReduxProvider store={store}>
        <RouterProvider>
          <div className="content">
            <Header/>
            {routes}
            <Footer/>
          </div>
        </RouterProvider>
      </ReduxProvider>
    )
  }
}

const mountPoint = document.getElementById('app')
render(<App/>, mountPoint)

感谢您的帮助

0 个答案:

没有答案