Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

how do add or change global variable hook?#528

Unanswered
exqmjmz asked this question inQ&A
Discussion options

I want to add new attr to the currentUser global variable.The new attr is elements.This attr is use to get user app with permissions.

client\packages\lowcoder\src\comps\hooks\hookComp.tsx
add code:

constCurrentUserHookComp=hookToStateComp(()=>{constuser=useCurrentUser();constelements=useSelector(folderElementsSelector)[""];constelementsAny:any[]=elements.map((item)=>itemasany);constupdatedUser={    ...user,elements:elementsAny};returnupdatedUser;});

an error occurred
How should I implement add custom hook?
error msg

ncaught Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.    at checkForNestedUpdates (react-dom.development.js:23803:15)    at scheduleUpdateOnFiber (react-dom.development.js:21835:3)    at dispatchAction (react-dom.development.js:16139:5)    at useDiffItem.js:19:5    at invokePassiveEffectCreate (react-dom.development.js:23487:20)    at HTMLUnknownElement.callCallback2 (react-dom.development.js:3945:14)    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:16)    at invokeGuardedCallback (react-dom.development.js:4056:31)    at flushPassiveEffectsImpl (react-dom.development.js:23574:9)    at unstable_runWithPriority (scheduler.development.js:468:12)checkForNestedUpdates @ react-dom.development.js:23803scheduleUpdateOnFiber @ react-dom.development.js:21835dispatchAction @ react-dom.development.js:16139(anonymous) @ useDiffItem.js:19invokePassiveEffectCreate @ react-dom.development.js:23487callCallback2 @ react-dom.development.js:3945invokeGuardedCallbackDev @ react-dom.development.js:3994invokeGuardedCallback @ react-dom.development.js:4056flushPassiveEffectsImpl @ react-dom.development.js:23574unstable_runWithPriority @ scheduler.development.js:468runWithPriority$1 @ react-dom.development.js:11276flushPassiveEffects @ react-dom.development.js:23447performSyncWorkOnRoot @ react-dom.development.js:22269(anonymous) @ react-dom.development.js:11327unstable_runWithPriority @ scheduler.development.js:468runWithPriority$1 @ react-dom.development.js:11276flushSyncCallbackQueueImpl @ react-dom.development.js:11322flushSyncCallbackQueue @ react-dom.development.js:11309scheduleUpdateOnFiber @ react-dom.development.js:21893dispatchAction @ react-dom.development.js:16139forceUpdate2 @ useKeyRecords.js:29(anonymous) @ useKeyRecords.js:46Promise.then(异步)nextSlice @ timeUtil.js:3(anonymous) @ useKeyRecords.js:44(anonymous) @ MenuItem.js:200invokePassiveEffectCreate @ react-dom.development.js:23487callCallback2 @ react-dom.development.js:3945invokeGuardedCallbackDev @ react-dom.development.js:3994invokeGuardedCallback @ react-dom.development.js:4056flushPassiveEffectsImpl @ react-dom.development.js:23574unstable_runWithPriority @ scheduler.development.js:468runWithPriority$1 @ react-dom.development.js:11276flushPassiveEffects @ react-dom.development.js:23447performSyncWorkOnRoot @ react-dom.development.js:22269(anonymous) @ react-dom.development.js:11327unstable_runWithPriority @ scheduler.development.js:468runWithPriority$1 @ react-dom.development.js:11276flushSyncCallbackQueueImpl @ react-dom.development.js:11322flushSyncCallbackQueue @ react-dom.development.js:11309scheduleUpdateOnFiber @ react-dom.development.js:21893dispatchAction @ react-dom.development.js:16139Promise.then(异步)useCompInstance @ useCompInstance.tsx:297useRootCompInstance @ appEditorInternal.tsx:90AppEditor @ AppEditor.tsx:68renderWithHooks @ react-dom.development.js:14985updateFunctionComponent @ react-dom.development.js:17356beginWork @ react-dom.development.js:19063beginWork$1 @ react-dom.development.js:23940performUnitOfWork @ react-dom.development.js:22776workLoopSync @ react-dom.development.js:22707renderRootSync @ react-dom.development.js:22670performSyncWorkOnRoot @ react-dom.development.js:22293(anonymous) @ react-dom.development.js:11327unstable_runWithPriority @ scheduler.development.js:468runWithPriority$1 @ react-dom.development.js:11276flushSyncCallbackQueueImpl @ react-dom.development.js:11322flushSyncCallbackQueue @ react-dom.development.js:11309scheduleUpdateOnFiber @ react-dom.development.js:21893dispatchAction @ react-dom.development.js:16139onSuccess @ AppEditor.tsx:117fetchApplicationDetailSaga @ applicationSagas.ts:219next @ redux-saga-core.esm.js:1157currCb @ redux-saga-core.esm.js:1251Promise.then(异步)resolvePromise @ redux-saga-core.esm.js:395runCallEffect @ redux-saga-core.esm.js:527runEffect @ redux-saga-core.esm.js:1204digestEffect @ redux-saga-core.esm.js:1271next @ redux-saga-core.esm.js:1161proc @ redux-saga-core.esm.js:1108(anonymous) @ redux-saga-core.esm.js:585immediately @ redux-saga-core.esm.js:56runForkEffect @ redux-saga-core.esm.js:584runEffect @ redux-saga-core.esm.js:1204digestEffect @ redux-saga-core.esm.js:1271next @ redux-saga-core.esm.js:1161currCb @ redux-saga-core.esm.js:1251takeCb2 @ redux-saga-core.esm.js:503put @ redux-saga-core.esm.js:339(anonymous) @ redux-saga-core.esm.js:376exec @ redux-saga-core.esm.js:31flush @ redux-saga-core.esm.js:87asap @ redux-saga-core.esm.js:46runPutEffect @ redux-saga-core.esm.js:468runEffect @ redux-saga-core.esm.js:1204digestEffect @ redux-saga-core.esm.js:1271next @ redux-saga-core.esm.js:1161currCb @ redux-saga-core.esm.js:1251Promise.then(异步)resolvePromise @ redux-saga-core.esm.js:395runCallEffect @ redux-saga-core.esm.js:527runEffect @ redux-saga-core.esm.js:1204digestEffect @ redux-saga-core.esm.js:1271next @ redux-saga-core.esm.js:1161proc @ redux-saga-core.esm.js:1108(anonymous) @ redux-saga-core.esm.js:585immediately @ redux-saga-core.esm.js:56runForkEffect @ redux-saga-core.esm.js:584runEffect @ redux-saga-core.esm.js:1204digestEffect @ redux-saga-core.esm.js:1271next @ redux-saga-core.esm.js:1161currCb @ redux-saga-core.esm.js:1251takeCb2 @ redux-saga-core.esm.js:503put @ redux-saga-core.esm.js:339(anonymous) @ redux-saga-core.esm.js:376exec @ redux-saga-core.esm.js:31flush @ redux-saga-core.esm.js:87asap @ redux-saga-core.esm.js:46chan.put @ redux-saga-core.esm.js:375(anonymous) @ redux-saga-core.esm.js:1412dispatchRecurse @ reduxBatch.js:60dispatch @ reduxBatch.js:72getCurrentUser @ app.tsx:181componentDidMount @ app.tsx:84commitLifeCycles @ react-dom.development.js:20663commitLayoutEffects @ react-dom.development.js:23426callCallback2 @ react-dom.development.js:3945invokeGuardedCallbackDev @ react-dom.development.js:3994invokeGuardedCallback @ react-dom.development.js:4056commitRootImpl @ react-dom.development.js:23151unstable_runWithPriority @ scheduler.development.js:468runWithPriority$1 @ react-dom.development.js:11276commitRoot @ react-dom.development.js:22990performSyncWorkOnRoot @ react-dom.development.js:22329scheduleUpdateOnFiber @ react-dom.development.js:21881updateContainer @ react-dom.development.js:25482(anonymous) @ react-dom.development.js:26021unbatchedUpdates @ react-dom.development.js:22431legacyRenderSubtreeIntoContainer @ react-dom.development.js:26020render @ react-dom.development.js:26103bootstrap @ app.tsx:191(anonymous) @ index.ts:39Show 121 more frames显示简略信息useCompInstance.tsx:297  The above error occurred in the <List> component:    at RawList (http://localhost:8000/node_modules/.vite/deps/chunk-MHNYKA2V.js?v=ea53131c:769:32)    at http://localhost:8000/node_modules/.vite/deps/chunk-LQEMSYXI.js?v=ea53131c:1891:29    at div    at Tree2 (http://localhost:8000/node_modules/.vite/deps/chunk-LQEMSYXI.js?v=ea53131c:2287:9)    at http://localhost:8000/node_modules/.vite/deps/antd.js?v=ea53131c:56619:30    at DirectoryTree (http://localhost:8000/node_modules/.vite/deps/antd.js?v=ea53131c:56806:5)    at P2 (http://localhost:8000/node_modules/.vite/deps/styled-components.js?v=ea53131c:1129:6)    at span    at div    at P2 (http://localhost:8000/node_modules/.vite/deps/styled-components.js?v=ea53131c:1129:6)    at div    at P2 (http://localhost:8000/node_modules/.vite/deps/styled-components.js?v=ea53131c:1129:6)    at BaseSection (http://localhost:8000/@fs/D:/code/lowcoder-2.1.7/client/packages/lowcoder-design/src/components/Section.tsx:97:5)    at div    at div    at div    at div    at div    at div    at div    at http://localhost:8000/node_modules/.vite/deps/simplebar-react.js?v=ea53131c:1908:23    at div    at P2 (http://localhost:8000/node_modules/.vite/deps/styled-components.js?v=ea53131c:1129:6)    at ScrollBar (http://localhost:8000/@fs/D:/code/lowcoder-2.1.7/client/packages/lowcoder-design/src/components/ScrollBar.tsx:54:5)    at div    at P2 (http://localhost:8000/node_modules/.vite/deps/styled-components.js?v=ea53131c:1129:6)    at LeftContent (http://localhost:8000/src/pages/editor/LeftContent.tsx:274:5)    at div    at Card (http://localhost:8000/src/pages/common/styledComponent.tsx:35:3)    at P2 (http://localhost:8000/node_modules/.vite/deps/styled-components.js?v=ea53131c:1129:6)    at div    at P2 (http://localhost:8000/node_modules/.vite/deps/styled-components.js?v=ea53131c:1129:6)    at div    at GlobalShortcutsWrapper (http://localhost:8000/src/util/keyUtils.tsx:158:5)    at EditorGlobalHotKeys (http://localhost:8000/src/pages/editor/editorHotKeys.tsx:101:23)    at div    at P2 (http://localhost:8000/node_modules/.vite/deps/styled-components.js?v=ea53131c:1129:6)    at EditorView (http://localhost:8000/src/pages/editor/editorView.tsx:189:5)    at div    at RootView (http://localhost:8000/src/comps/comps/rootComp.tsx?t=1701005699334:56:24)    at LocaleProvider (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:2594:13)    at MotionWrapper (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:3853:5)    at ProviderChildren (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:3962:5)    at ConfigProvider (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:4182:27)    at AppEditorInternalView (http://localhost:8000/src/pages/editor/appEditorInternal.tsx?t=1701005699334:109:26)    at AppEditor (http://localhost:8000/src/pages/editor/AppEditor.tsx?t=1701005699334:43:27)    at Route2 (http://localhost:8000/node_modules/.vite/deps/chunk-4Z54LJ33.js?v=ea53131c:942:29)    at Switch2 (http://localhost:8000/node_modules/.vite/deps/chunk-4Z54LJ33.js?v=ea53131c:1086:29)    at Router2 (http://localhost:8000/node_modules/.vite/deps/chunk-4Z54LJ33.js?v=ea53131c:655:30)    at div    at App (http://localhost:8000/node_modules/.vite/deps/antd.js?v=ea53131c:17366:16)    at LocaleProvider (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:2594:13)    at MotionWrapper (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:3853:5)    at ProviderChildren (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:3962:5)    at ConfigProvider (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:4182:27)    at Wrapper (http://localhost:8000/src/app.tsx?t=1701005699334:69:23)    at AppIndex (http://localhost:8000/src/app.tsx?t=1701005699334:81:1)    at ConnectFunction (http://localhost:8000/node_modules/.vite/deps/react-redux.js?v=ea53131c:543:48)    at Provider (http://localhost:8000/node_modules/.vite/deps/react-redux.js?v=ea53131c:371:20)Consider adding an error boundary to your tree to customize error handling behavior.Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.
useCompInstance.tsx:297  The above error occurred in the <List> component:    at RawList (http://localhost:8000/node_modules/.vite/deps/chunk-MHNYKA2V.js?v=ea53131c:769:32)    at http://localhost:8000/node_modules/.vite/deps/chunk-LQEMSYXI.js?v=ea53131c:1891:29    at div    at Tree2 (http://localhost:8000/node_modules/.vite/deps/chunk-LQEMSYXI.js?v=ea53131c:2287:9)    at http://localhost:8000/node_modules/.vite/deps/antd.js?v=ea53131c:56619:30    at DirectoryTree (http://localhost:8000/node_modules/.vite/deps/antd.js?v=ea53131c:56806:5)    at P2 (http://localhost:8000/node_modules/.vite/deps/styled-components.js?v=ea53131c:1129:6)    at span    at div    at P2 (http://localhost:8000/node_modules/.vite/deps/styled-components.js?v=ea53131c:1129:6)    at div    at P2 (http://localhost:8000/node_modules/.vite/deps/styled-components.js?v=ea53131c:1129:6)    at BaseSection (http://localhost:8000/@fs/D:/code/lowcoder-2.1.7/client/packages/lowcoder-design/src/components/Section.tsx:97:5)    at div    at div    at div    at div    at div    at div    at div    at http://localhost:8000/node_modules/.vite/deps/simplebar-react.js?v=ea53131c:1908:23    at div    at P2 (http://localhost:8000/node_modules/.vite/deps/styled-components.js?v=ea53131c:1129:6)    at ScrollBar (http://localhost:8000/@fs/D:/code/lowcoder-2.1.7/client/packages/lowcoder-design/src/components/ScrollBar.tsx:54:5)    at div    at P2 (http://localhost:8000/node_modules/.vite/deps/styled-components.js?v=ea53131c:1129:6)    at LeftContent (http://localhost:8000/src/pages/editor/LeftContent.tsx:274:5)    at div    at Card (http://localhost:8000/src/pages/common/styledComponent.tsx:35:3)    at P2 (http://localhost:8000/node_modules/.vite/deps/styled-components.js?v=ea53131c:1129:6)    at div    at P2 (http://localhost:8000/node_modules/.vite/deps/styled-components.js?v=ea53131c:1129:6)    at div    at GlobalShortcutsWrapper (http://localhost:8000/src/util/keyUtils.tsx:158:5)    at EditorGlobalHotKeys (http://localhost:8000/src/pages/editor/editorHotKeys.tsx:101:23)    at div    at P2 (http://localhost:8000/node_modules/.vite/deps/styled-components.js?v=ea53131c:1129:6)    at EditorView (http://localhost:8000/src/pages/editor/editorView.tsx:189:5)    at div    at RootView (http://localhost:8000/src/comps/comps/rootComp.tsx?t=1701005699334:56:24)    at LocaleProvider (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:2594:13)    at MotionWrapper (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:3853:5)    at ProviderChildren (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:3962:5)    at ConfigProvider (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:4182:27)    at AppEditorInternalView (http://localhost:8000/src/pages/editor/appEditorInternal.tsx?t=1701005699334:109:26)    at AppEditor (http://localhost:8000/src/pages/editor/AppEditor.tsx?t=1701005699334:43:27)    at Route2 (http://localhost:8000/node_modules/.vite/deps/chunk-4Z54LJ33.js?v=ea53131c:942:29)    at Switch2 (http://localhost:8000/node_modules/.vite/deps/chunk-4Z54LJ33.js?v=ea53131c:1086:29)    at Router2 (http://localhost:8000/node_modules/.vite/deps/chunk-4Z54LJ33.js?v=ea53131c:655:30)    at div    at App (http://localhost:8000/node_modules/.vite/deps/antd.js?v=ea53131c:17366:16)    at LocaleProvider (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:2594:13)    at MotionWrapper (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:3853:5)    at ProviderChildren (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:3962:5)    at ConfigProvider (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:4182:27)    at Wrapper (http://localhost:8000/src/app.tsx?t=1701005699334:69:23)    at AppIndex (http://localhost:8000/src/app.tsx?t=1701005699334:81:1)    at ConnectFunction (http://localhost:8000/node_modules/.vite/deps/react-redux.js?v=ea53131c:543:48)    at Provider (http://localhost:8000/node_modules/.vite/deps/react-redux.js?v=ea53131c:371:20)Consider adding an error boundary to your tree to customize error handling behavior.Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.
react-dom.development.js:23803  Uncaught (in promise) Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.    at checkForNestedUpdates (react-dom.development.js:23803:15)    at scheduleUpdateOnFiber (react-dom.development.js:21835:3)    at dispatchAction (react-dom.development.js:16139:5)    at useDiffItem.js:19:5    at invokePassiveEffectCreate (react-dom.development.js:23487:20)    at HTMLUnknownElement.callCallback2 (react-dom.development.js:3945:14)    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:16)    at invokeGuardedCallback (react-dom.development.js:4056:31)    at flushPassiveEffectsImpl (react-dom.development.js:23574:9)    at unstable_runWithPriority (scheduler.development.js:468:12)    ```            ```    react-dom.development.js:67  Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.    at Overflow (http://localhost:8000/node_modules/.vite/deps/antd.js?v=ea53131c:20215:32)    at InheritableContextProvider (http://localhost:8000/node_modules/.vite/deps/antd.js?v=ea53131c:20628:23)    at http://localhost:8000/node_modules/.vite/deps/antd.js?v=ea53131c:22431:43    at http://localhost:8000/node_modules/.vite/deps/antd.js?v=ea53131c:24499:29    at http://localhost:8000/node_modules/.vite/deps/antd.js?v=ea53131c:24603:45    at div    at aside    at http://localhost:8000/node_modules/.vite/deps/antd_lib_layout_Sider.js?v=ea53131c:798:20    at div    at P2 (http://localhost:8000/node_modules/.vite/deps/styled-components.js?v=ea53131c:1129:6)    at div    at P2 (http://localhost:8000/node_modules/.vite/deps/styled-components.js?v=ea53131c:1129:6)    at div    at GlobalShortcutsWrapper (http://localhost:8000/src/util/keyUtils.tsx:158:5)    at EditorGlobalHotKeys (http://localhost:8000/src/pages/editor/editorHotKeys.tsx:101:23)    at div    at P2 (http://localhost:8000/node_modules/.vite/deps/styled-components.js?v=ea53131c:1129:6)    at EditorView (http://localhost:8000/src/pages/editor/editorView.tsx:189:5)    at div    at RootView (http://localhost:8000/src/comps/comps/rootComp.tsx?t=1701005699334:56:24)    at LocaleProvider (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:2594:13)    at MotionWrapper (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:3853:5)    at ProviderChildren (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:3962:5)    at ConfigProvider (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:4182:27)    at AppEditorInternalView (http://localhost:8000/src/pages/editor/appEditorInternal.tsx?t=1701005699334:109:26)    at AppEditor (http://localhost:8000/src/pages/editor/AppEditor.tsx?t=1701005699334:43:27)    at Route2 (http://localhost:8000/node_modules/.vite/deps/chunk-4Z54LJ33.js?v=ea53131c:942:29)    at Switch2 (http://localhost:8000/node_modules/.vite/deps/chunk-4Z54LJ33.js?v=ea53131c:1086:29)    at Router2 (http://localhost:8000/node_modules/.vite/deps/chunk-4Z54LJ33.js?v=ea53131c:655:30)    at div    at App (http://localhost:8000/node_modules/.vite/deps/antd.js?v=ea53131c:17366:16)    at LocaleProvider (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:2594:13)    at MotionWrapper (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:3853:5)    at ProviderChildren (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:3962:5)    at ConfigProvider (http://localhost:8000/node_modules/.vite/deps/chunk-NMSLX2TJ.js?v=ea53131c:4182:27)    at Wrapper (http://localhost:8000/src/app.tsx?t=1701005699334:69:23)    at AppIndex (http://localhost:8000/src/app.tsx?t=1701005699334:81:1)    at ConnectFunction (http://localhost:8000/node_modules/.vite/deps/react-redux.js?v=ea53131c:543:48)    at Provider (http://localhost:8000/node_modules/.vite/deps/react-redux.js?v=ea53131c:371:20)    ```
You must be logged in to vote

Replies: 0 comments

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
1 participant
@exqmjmz

[8]ページ先頭

©2009-2025 Movatter.jp