remove the annoying key duplication warning
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, react, typescript
- Ambito
- frontend
Direzione di ricerca
Inizia individuando il codice sorgente corrispondente a node_modules/rc-menu/es/hooks/useKeyRecords.js e l’avviso esistente relativo alle chiavi duplicate. Confronta il diff segnalato con il codice sorgente e i test del repository; il lavoro è completato quando il comportamento dell’avviso viene modificato intenzionalmente senza modificare i file delle dipendenze generati, con una copertura per le chiavi di menu interessate.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected] for the project I'm working on.
Here is the diff that solved my problem:
diff --git a/node_modules/rc-menu/es/hooks/useKeyRecords.js b/node_modules/rc-menu/es/hooks/useKeyRecords.js
index 1afe5c8..d09e433 100644
--- a/node_modules/rc-menu/es/hooks/useKeyRecords.js
+++ b/node_modules/rc-menu/es/hooks/useKeyRecords.js
@@ -1,17 +1,17 @@
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
-import * as React from 'react';
-import { useRef, useCallback } from 'react';
+import * as React from "react";
+import { useRef, useCallback } from "react";
import warning from "rc-util/es/warning";
import { nextSlice } from "../utils/timeUtil";
-var PATH_SPLIT = '__RC_UTIL_PATH_SPLIT__';
+var PATH_SPLIT = "__RC_UTIL_PATH_SPLIT__";
var getPathStr = function getPathStr(keyPath) {
return keyPath.join(PATH_SPLIT);
};
var getPathKeys = function getPathKeys(keyPathStr) {
return keyPathStr.split(PATH_SPLIT);
};
-export var OVERFLOW_KEY = 'rc-menu-more';
+export var OVERFLOW_KEY = "rc-menu-more";
export default function useKeyRecords() {
var _React$useState = React.useState({}),
_React$useState2 = _slicedToArray(_React$useState, 2),
@@ -31,9 +31,9 @@ export default function useKeyRecords() {
};
var registerPath = useCallback(function (key, keyPath) {
// Warning for invalidate or duplicated `key`
- if (process.env.NODE_ENV !== 'production') {
- warning(!key2pathRef.current.has(key), "Duplicated key '".concat(key, "' used in Menu by path [").concat(keyPath.join(' > '), "]"));
- }
+ // if (process.env.NODE_ENV !== 'production') {
+ // warning(!key2pathRef.current.has(key), "Duplicated key '".concat(key, "' used in Menu by path [").concat(keyPath.join(' > '), "]"));
+ // }
// Fill map
var connectedPath = getPathStr(keyPath);
@@ -55,22 +55,30 @@ export default function useKeyRecords() {
var refreshOverflowKeys = useCallback(function (keys) {
setOverflowKeys(keys);
}, []);
- var getKeyPath = useCallback(function (eventKey, includeOverflow) {
- var fullPath = key2pathRef.current.get(eventKey) || '';
- var keys = getPathKeys(fullPath);
- if (includeOverflow && overflowKeys.includes(keys[0])) {
- keys.unshift(OVERFLOW_KEY);
- }
- return keys;
- }, [overflowKeys]);
- var isSubPathKey = useCallback(function (pathKeys, eventKey) {
- return pathKeys.filter(function (item) {
- return item !== undefined;
- }).some(function (pathKey) {
- var pathKeyList = getKeyPath(pathKey, true);
- return pathKeyList.includes(eventKey);
- });
- }, [getKeyPath]);
+ var getKeyPath = useCallback(
+ function (eventKey, includeOverflow) {
+ var fullPath = key2pathRef.current.get(eventKey) || "";
+ var keys = getPathKeys(fullPath);
+ if (includeOverflow && overflowKeys.includes(keys[0])) {
+ keys.unshift(OVERFLOW_KEY);
+ }
+ return keys;
+ },
+ [overflowKeys],
+ );
+ var isSubPathKey = useCallback(
+ function (pathKeys, eventKey) {
+ return pathKeys
+ .filter(function (item) {
+ return item !== undefined;
+ })
+ .some(function (pathKey) {
+ var pathKeyList = getKeyPath(pathKey, true);
+ return pathKeyList.includes(eventKey);
+ });
+ },
+ [getKeyPath],
+ );
var getKeys = function getKeys() {
var keys = _toConsumableArray(key2pathRef.current.keys());
if (overflowKeys.length) {
@@ -83,7 +91,9 @@ export default function useKeyRecords() {
* Find current key related child path keys
*/
var getSubPathKeys = useCallback(function (key) {
- var connectedPath = "".concat(key2pathRef.current.get(key)).concat(PATH_SPLIT);
+ var connectedPath = ""
+ .concat(key2pathRef.current.get(key))
+ .concat(PATH_SPLIT);
var pathKeys = new Set();
_toConsumableArray(path2keyRef.current.keys()).forEach(function (pathKey) {
if (pathKey.startsWith(connectedPath)) {
@@ -106,6 +116,6 @@ export default function useKeyRecords() {
isSubPathKey: isSubPathKey,
getKeyPath: getKeyPath,
getKeys: getKeys,
- getSubPathKeys: getSubPathKeys
+ getSubPathKeys: getSubPathKeys,
};
}
This issue body was partially generated by patch-package.
- Lingua principale
- TypeScript
- Stelle
- 701
- Fork
- 266
- Merge medio
- 1g 9h
- PR unite (30g)
- 1
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di react-component/menu
-
封装 Menu 子组件时导致的 key 不能正常传递的坑Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
react-component/menu#833 · 1 commento ·
-
HoAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 1/100
react-component/menu#790 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
react-component/menu#742 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
react-component/menu#732 · 1 reazione ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 20/100
react-component/menu#729 ·
Tutte le issue di react-component/menu
Issue simili
-
bot:ai-assisted status:untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
midnightntwrk/midnight-js#1424 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
mksglu/context-mode#1268 ·
I maintainer di solito rispondono entro 5 giorni
-
[bug] Setup fails with "Cannot find matching keyid" when an older Node's corepack is on PATHForse già presa @EyalPoly l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
MystenLabs/MemWal#1124 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Edit:Apertacheck:failed streams:edit
Difficoltà 2/5 1-3 ore Idoneità per principianti 60/100
iptv-org/iptv#54352 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno