大佬教程收集整理的这篇文章主要介绍了类型错误:history__WEBPACK_IMPORTED_MODULE_0__.Action 未定义,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我尝试按照教程使用路由反应应用程序设置 gh-pages。
在我的 index.Js 中,我将路由与 HashRouter 包装如下,因为他们告诉 HashRouter 用于处理 gh-pages,以便 gh-pages 可以识别路由。 :
import React from 'react';
import ReactDOM from 'react-dom';
import Upload from './components/Upload';
import display from './components/display';
import Callback from './components/Callback';
import reportWebVitals from './reportWebVitals'
import { Router,Route,browserHistory } from 'react-router';
import { requireAuth } from './utils/AuthService';
import { HashRouter } from "react-router-dom"
const Root = () => {
return (
<div classname="container">
<HashRouter history={browserHistory}>
<Route path="/" component={display}/>
<Route path="/upload" component={Upload} onEnter={requireAuth} />
<Route path="/callback" component={Callback} />
</HashRouter >
</div>
)
}
ReactDOM.render(<Root />,document.getElementByID('root'));
reportWebVitals();
但我在运行 npm start 时收到此错误:
TypeError: history__WEBPACK_importED_MODulE_0__.Action is undefined
x
http://localhost:3000/miniflix/static/Js/vendors~main.chunk.Js:42755:7
renderWithHooks
node_modules/react-dom/cJs/react-dom.development.Js:14985
14982 | }
14983 | }
14984 |
> 14985 | var children = Component(props,secondArg); // Check if there was a render phase update
| ^ 14986 |
14987 | if (dIDScheduleRenderPhaseUpdateDuringThisPass) {
14988 | // Keep rendering in a loop for as long as render phase updates continue to
mountIndeterminateComponent
node_modules/react-dom/cJs/react-dom.development.Js:17811
17808 |
17809 | setIsRendering(true);
17810 | ReactCurrentOwner$1.current = workInProgress;
> 17811 | value = renderWithHooks(null,workInProgress,Component,props,context,renderLanes);
| ^ 17812 | setIsRendering(false);
17813 | } // React DevTools reads this flag.
17814 |
beginWork
node_modules/react-dom/cJs/react-dom.development.Js:19049
19046 | switch (workInProgress.tag) {
19047 | case IndeterminateComponent:
19048 | {
> 19049 | return mountIndeterminateComponent(current,workInProgress.type,renderLanes);
| ^ 19050 | }
19051 |
19052 | case LazyComponent:
callCallback
node_modules/react-dom/cJs/react-dom.development.Js:3945
3942 | function callCallback() {
3943 | dIDCall = true;
3944 | restoreAfterdispatch();
> 3945 | func.apply(context,funcArgs);
| ^ 3946 | dIDError = false;
3947 | } // Create a global error event handler. We use this to capture the value
3948 | // that was thrown. It's possible that this error handler will fire more
invokeGuardedCallbackDev
node_modules/react-dom/cJs/react-dom.development.Js:3994
3991 | // errors,it will trigger our global error handler.
3992 |
3993 | evt.initEvent(evtType,false,false);
> 3994 | fakeNode.dispatchEvent(evt);
| ^ 3995 |
3996 | if (windowEventDescriptor) {
3997 | Object.defineProperty(window,'event',windowEventDescriptor);
invokeGuardedCallback
node_modules/react-dom/cJs/react-dom.development.Js:4056
4053 | function invokeGuardedCallback(name,func,a,b,c,d,e,f) {
4054 | hasError = false;
4055 | caughtError = null;
> 4056 | invokeGuardedCallbackImpl$1.apply(reporter,arguments);
4057 | }
4058 | /**
4059 | * Same as invokeGuardedCallback,but instead of returning an error,it stores
beginWork$1
node_modules/react-dom/cJs/react-dom.development.Js:23964
23961 | } // Run beginWork again.
23962 |
23963 |
> 23964 | invokeGuardedCallback(null,beginWork,null,current,unitOfWork,lanes);
| ^ 23965 |
23966 | if (hasCaughtError()) {
23967 | var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`.
performunitOfWork
node_modules/react-dom/cJs/react-dom.development.Js:22776
22773 |
22774 | if ( (unitOfWork.mode & ProfileMode) !== NoMode) {
22775 | startProfilerTimer(unitOfWork);
> 22776 | next = beginWork$1(current,subtreeRenderLanes);
| ^ 22777 | stopProfilerTimerIfRunningAndRecordDelta(unitOfWork,true);
22778 | } else {
22779 | next = beginWork$1(current,subtreeRenderLanes);
workLoopSync
node_modules/react-dom/cJs/react-dom.development.Js:22707
22704 | function workLoopSync() {
22705 | // Already timed out,so perform work without checking if we need to yIEld.
22706 | while (workInProgress !== null) {
> 22707 | performunitOfWork(workInProgress);
22708 | }
22709 | }
22710 |
renderRootSync
node_modules/react-dom/cJs/react-dom.development.Js:22670
22667 |
22668 | do {
22669 | try {
> 22670 | workLoopSync();
| ^ 22671 | break;
22672 | } catch (thrownValue) {
22673 | handleError(root,thrownValue);
performSyncWorkOnRoot
node_modules/react-dom/cJs/react-dom.development.Js:22293
22290 | }
22291 | } else {
22292 | lanes = getNextLanes(root,Nolanes);
> 22293 | exitStatus = renderRootSync(root,lanes);
| ^ 22294 | }
22295 |
22296 | if (root.tag !== LegacyRoot && exitStatus === RootErrored) {
scheduleUpdateOnFiber
node_modules/react-dom/cJs/react-dom.development.Js:21881
21878 | // root insIDe of batchedUpdates should be synchronous,but layout updates
21879 | // should be deferred until the end of the batch.
21880 |
> 21881 | performSyncWorkOnRoot(root);
| ^ 21882 | } else {
21883 | ensureRootIsScheduled(root,eventTime);
21884 | schedulePendingInteractions(root,lane);
updateContainer
node_modules/react-dom/cJs/react-dom.development.Js:25482
25479 | }
25480 |
25481 | enqueueUpdate(current$1,update);
> 25482 | scheduleUpdateOnFiber(current$1,lane,eventTime);
25483 | return lane;
25484 | }
25485 | function getPublicRootInstance(container) {
legacyRenderSubtreeIntoContainer/<
node_modules/react-dom/cJs/react-dom.development.Js:26021
26018 |
26019 |
26020 | unbatchedUpdates(function () {
> 26021 | updateContainer(children,fiberRoot,parentComponent,callback);
| ^ 26022 | });
26023 | } else {
26024 | fiberRoot = root._internalRoot;
unbatchedUpdates
node_modules/react-dom/cJs/react-dom.development.Js:22431
22428 | executionContext |= LegacyUnbatchedContext;
22429 |
22430 | try {
> 22431 | return fn(a);
| ^ 22432 | } finally {
22433 | executionContext = prevExecutionContext;
22434 |
legacyRenderSubtreeIntoContainer
node_modules/react-dom/cJs/react-dom.development.Js:26020
26017 | } // Initial mount should not be batched.
26018 |
26019 |
> 26020 | unbatchedUpdates(function () {
| ^ 26021 | updateContainer(children,callback);
26022 | });
26023 | } else {
render
node_modules/react-dom/cJs/react-dom.development.Js:26103
26100 | }
26101 | }
26102 |
> 26103 | return legacyRenderSubtreeIntoContainer(null,element,container,callback);
26104 | }
26105 | function unstable_renderSubtreeIntoContainer(parentComponent,containerNode,callback) {
26106 | if (!isValIDContainer(containerNode)) {
./src/index.Js/<
src/index.Js:23
20 | )
21 | }
22 |
> 23 | ReactDOM.render(<Root />,document.getElementByID('root'));
24 | reportWebVitals();
25 |
./src/index.Js
http://localhost:3000/miniflix/static/Js/main.chunk.Js:880:30
__webpack_require__
/home/pc/documents/vIDeo_streaming/miniflix/webpack/bootstrap:856
853 |
854 | __webpack_require__.$Refresh$.init();
855 | try {
> 856 | modules[moduleID].call(module.exports,module,module.exports,hotCreateRequire(moduleID));
| ^ 857 | } finally {
858 | __webpack_require__.$Refresh$.cleanup(moduleID);
859 | }
fn
/home/pc/documents/vIDeo_streaming/miniflix/webpack/bootstrap:150
147 | );
148 | hotCurrentParents = [];
149 | }
> 150 | return __webpack_require__(request);
| ^ 151 | };
152 | var ObjectFactory = function ObjectFactory(name) {
153 | return {
1
http://localhost:3000/miniflix/static/Js/main.chunk.Js:1190:18
__webpack_require__
/home/pc/documents/vIDeo_streaming/miniflix/webpack/bootstrap:856
853 |
854 | __webpack_require__.$Refresh$.init();
855 | try {
> 856 | modules[moduleID].call(module.exports,hotCreateRequire(moduleID));
| ^ 857 | } finally {
858 | __webpack_require__.$Refresh$.cleanup(moduleID);
859 | }
checkDeferredModules
/home/pc/documents/vIDeo_streaming/miniflix/webpack/bootstrap:45
42 | }
43 | if(fulfilled) {
44 | deferredModules.splice(i--,1);
> 45 | result = __webpack_require__(__webpack_require__.s = deferredModule[0]);
| ^ 46 | }
47 | }
48 |
webpackJsonpCallback
/home/pc/documents/vIDeo_streaming/miniflix/webpack/bootstrap:32
29 | deferredModules.push.apply(deferredModules,executeModules || []);
30 |
31 | // run deferred modules when all chunks ready
> 32 | return checkDeferredModules();
| ^ 33 | };
34 | function checkDeferredModules() {
35 | var result;
(anonymous function)
http://localhost:3000/miniflix/static/Js/main.chunk.Js:1:69
我不明白发生了什么,这是我的 package.Json 文件:
{
"name": "miniflix","version": "0.1.0","private": true,"homepage": "http://aoyuzhang.github.io/miniflix","dependencIEs": {
"@testing-library/jest-dom": "^5.12.0","@testing-library/react": "^11.2.7","@testing-library/user-event": "^12.8.3","auth0-Js": "^9.16.0","axios": "^0.21.1","jwt-decode": "^3.1.2","react": "^17.0.2","react-dom": "^17.0.2","react-router": "^3.2.6","react-router-dom": "^6.0.0-beta.0","react-scripts": "4.0.3","web-vitals": "^1.1.2"
},"scripts": {
"start": "react-scripts start","build": "react-scripts build","test": "react-scripts test","eject": "react-scripts eject","predeploy": "npm run build","deploy": "gh-pages -d build"
},"eslintConfig": {
"extends": [
"react-app","react-app/jest"
]
},"browsersList": {
"production": [
">0.2%","not dead","not op_mini all"
],"development": [
"last 1 Chrome version","last 1 firefox version","last 1 safari version"
]
},"devDependencIEs": {
"gh-pages": "^3.1.0"
}
}
请帮忙
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的类型错误:history__WEBPACK_IMPORTED_MODULE_0__.Action 未定义全部内容,希望文章能够帮你解决类型错误:history__WEBPACK_IMPORTED_MODULE_0__.Action 未定义所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。