Not working under `Next.js`
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 30/100
Rechercherichtung
Beginne damit, das bereitgestellte Beispiel in einem Next.js-Projekt nachzubilden und die Seite in einem Browser auszuführen, wobei du die Interaktionen des Baums überprüfst. Die Aufgabe ist erledigt, wenn der Baum sowohl korrekt gerendert wird als auch auf seine Interaktionen zum Erweitern, Auswählen, Abhaken, Bearbeiten, Löschen und Scrollen reagiert.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Paste the example into a Next.js project, and run this page in the browser, it could render the tree correctly but no interactions at all.
/* eslint-disable no-alert, no-console, react/no-find-dom-node */
import React from 'react';
import '../../assets/index.less';
import './basic.less';
import Tree, { TreeNode } from 'rc-tree';
const treeData = [
{
key: '0-0',
title: 'parent 1',
children: [
{ key: '0-0-0', title: 'parent 1-1', children: [{ key: '0-0-0-0', title: 'parent 1-1-0' }] },
{
key: '0-0-1',
title: 'parent 1-2',
children: [
{ key: '0-0-1-0', title: 'parent 1-2-0', disableCheckbox: true },
{ key: '0-0-1-1', title: 'parent 1-2-1' },
{ key: '0-0-1-2', title: 'parent 1-2-2' },
{ key: '0-0-1-3', title: 'parent 1-2-3' },
{ key: '0-0-1-4', title: 'parent 1-2-4' },
{ key: '0-0-1-5', title: 'parent 1-2-5' },
{ key: '0-0-1-6', title: 'parent 1-2-6' },
{ key: '0-0-1-7', title: 'parent 1-2-7' },
{ key: '0-0-1-8', title: 'parent 1-2-8' },
{ key: '0-0-1-9', title: 'parent 1-2-9' },
{ key: 1128, title: 1128 },
],
},
],
},
];
class Demo extends React.Component {
static defaultProps = {
keys: ['0-0-0-0'],
};
constructor(props) {
super(props);
const { keys } = props;
this.state = {
defaultExpandedKeys: keys,
defaultSelectedKeys: keys,
defaultCheckedKeys: keys,
};
this.treeRef = React.createRef();
}
onExpand = expandedKeys => {
console.log('onExpand', expandedKeys);
};
onSelect = (selectedKeys, info) => {
console.log('selected', selectedKeys, info);
this.selKey = info.node.props.eventKey;
};
onCheck = (checkedKeys, info) => {
console.log('onCheck', checkedKeys, info);
};
onEdit = () => {
setTimeout(() => {
console.log('current key: ', this.selKey);
}, 0);
};
onDel = e => {
if (!window.confirm('sure to delete?')) {
return;
}
e.stopPropagation();
};
setTreeRef = tree => {
this.tree = tree;
};
render() {
const customLabel = (
<span className="cus-label">
<span>operations: </span>
<span style={{ color: 'blue' }} onClick={this.onEdit}>
Edit
</span>
<label onClick={e => e.stopPropagation()}>
<input type="checkbox" /> checked
</label>
<span style={{ color: '#EB0000' }} onClick={this.onDel}>
Delete
</span>
</span>
);
return (
<div style={{ margin: '0 20px' }}>
<h2>simple</h2>
<input aria-label="good" />
<Tree
ref={this.setTreeRef}
className="myCls"
showLine
checkable
defaultExpandAll
defaultExpandedKeys={this.state.defaultExpandedKeys}
onExpand={this.onExpand}
defaultSelectedKeys={this.state.defaultSelectedKeys}
defaultCheckedKeys={this.state.defaultCheckedKeys}
onSelect={this.onSelect}
onCheck={this.onCheck}
onActiveChange={key => console.log('Active:', key)}
>
<TreeNode title="parent 1" key="0-0">
<TreeNode title={customLabel} key="0-0-0">
<TreeNode title="leaf" key="0-0-0-0" style={{ background: 'rgba(255, 0, 0, 0.1)' }} />
<TreeNode title="leaf" key="0-0-0-1" />
</TreeNode>
<TreeNode title="parent 1-1" key="0-0-1">
<TreeNode title="parent 1-1-0" key="0-0-1-0" disableCheckbox />
<TreeNode title="parent 1-1-1" key="0-0-1-1" />
</TreeNode>
<TreeNode title="parent 1-2" key="0-0-2" disabled>
<TreeNode title="parent 1-2-0" key="0-0-2-0" checkable={false} />
<TreeNode title="parent 1-2-1" key="0-0-2-1" />
</TreeNode>
</TreeNode>
</Tree>
<h2>Check on Click TreeNode</h2>
<Tree
className="myCls"
showLine
checkable
selectable={false}
defaultExpandAll
onExpand={this.onExpand}
defaultSelectedKeys={this.state.defaultSelectedKeys}
defaultCheckedKeys={this.state.defaultCheckedKeys}
onSelect={this.onSelect}
onCheck={this.onCheck}
treeData={treeData}
/>
<h2>Select</h2>
<Tree
ref={this.treeRef}
className="myCls"
defaultExpandAll
treeData={treeData}
onSelect={this.onSelect}
height={150}
/>
<button
type="button"
onClick={() => {
setTimeout(() => {
console.log('scroll!!!');
this.treeRef.current.scrollTo({ key: '0-0-1-9' });
}, 100);
}}
>
Scroll Last
</button>
</div>
);
}
}
export default Demo;
- Vorherrschende Sprache
- TypeScript
- Sterne
- 1.3k
- Forks
- 490
- Ø Merge
- 3 T. 17 Std.
- Gemergte PRs (30 T.)
- 5
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus react-component/tree
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 55/100
react-component/tree#1068 · 1 Kommentar ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 20/100
react-component/tree#983 ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
react-component/tree#937 ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
react-component/tree#935 ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
react-component/tree#929 ·
Alle Issues in react-component/tree
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
vercel-labs/just-bash#464 ·
-
looksLikeSlug() is ASCII-only, so non-Latin entity slugs (e.g. Korean) skip exact match and collapse Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
TanStack/tanstack.com#1293 ·