小编Has*_*eed的帖子

默认路由始终在React Router中执行

我正在开发一个使用引人注目的Dash 模板的项目。在这里,我在从 URL 更改路由时遇到一些路由问题。

auth.js

import React, { lazy, Suspense } from "react"
import { Spin } from "antd"
import { Switch, Route, Redirect } from "react-router-dom"
import AuthLayout from "../container/profile/authentication/Index"

const Login = lazy(() =>
  import("../container/profile/authentication/overview/SignIn")
)
const SignUp = lazy(() =>
  import("../container/profile/authentication/overview/SignUp")
)
const ForgetPassword = lazy(() =>
  import("../container/profile/authentication/overview/ForgetPassword")
)
const EmailConfirmation = lazy(() =>
  import("../container/profile/authentication/overview/EmailConfirmation")
)
const VerificationPage = lazy(() =>
  import("../container/profile/authentication/overview/VerificationPage")
)

const NotFound = () => {
  console.log("NOT FOUND")
  return <Redirect to="/" />
}

const …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-router react-router-dom react-hooks

9
推荐指数
1
解决办法
1788
查看次数

带有 WebPack 的 Bootstrap4 的数据表未集成在 Rails 6 中?

目前,我正在处理我正在处理考勤模块的人力资源系统。我想使用 Bootstrap4 DataTables 显示表格。我已经尝试了 StackOverflow 的所有链接,但没有一个解决方案适合我。

我在此代码中遇到以下错误:

application.js:1 未捕获的错误:在 webpackMissingModule (application.js:1) 中找不到模块“jquery”

出勤:131 未捕获的参考错误:$ 未在出勤:131 处定义

$(...)DataTable 不是函数

packages.json

    {
    "name": "inhouse_activities",
    "private": true,
    "dependencies": {
        "@fortawesome/fontawesome-free": "^5.15.0",
        "@nathanvda/cocoon": "^1.2.14",
        "@rails/actioncable": "^6.0.0",
        "@rails/activestorage": "^6.0.0",
        "@rails/ujs": "^6.0.0",
        "@rails/webpacker": "4.3.0",
        "bootstrap": "^4.5.2",
        "coffee-loader": "^1.0.0",
        "coffeescript": "1.12.7",
        "datatables.net": "^1.10.22",
        "datatables.net-bs4": "^1.10.22",
        "imports-loader": "^1.2.0",
        "jquery": "^3.5.1",
        "popper.js": "^1.16.1",
        "toastr": "^2.1.4",
        "turbolinks": "^5.2.0"
    },
    "version": "0.1.0",
    "devDependencies": {
        "webpack-dev-server": "^3.11.0"
    }
}
Run Code Online (Sandbox Code Playgroud)

config/webpack/loaders/datatable.js

module.exports = {
    test: /datatables\.net.*/,
    use: [{
      loader: 'imports-loader?define=>false'
    }] …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails datatables webpack bootstrap-4

7
推荐指数
0
解决办法
758
查看次数

saga React.js 中的 setTimeout 函数

我只想在 5 秒后隐藏 UI 中的撤消按钮。这是我的代码:

Saga.js

function* updateActionListingsSaga({ payload }) {
  try {
    const res = yield call(updateUnpublishedListingsById, payload);
    let unpublishedListings = yield select(UnpublishedListings);
    if (res) {
      const row = unpublishedListings.listingsData.results.find(data => data.id === res.ids[0])
      if (row) {
        row.review_status = payload.review_status
        row.isUndoEnabled = true;
        yield setTimeout(() => {row.isUndoEnabled = false}, 5000)
      }
    }
    
    yield put(updateActionListingSuccess());
  } catch (error) {
    yield put(apiError(error.error || error.message || error));
  }
}
Run Code Online (Sandbox Code Playgroud)

索引.js

item?.isUndoEnabled && (
  <ConfirmDialogBtn
    button={{
      color: 'primary',
      title: 'Undo',
      icon: 'bx bx-undo', …
Run Code Online (Sandbox Code Playgroud)

javascript saga reactjs redux-saga react-redux

6
推荐指数
0
解决办法
416
查看次数