Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

294
Views
react-sortable-tree - Cómo hacer funcionar la API de búsqueda

De acuerdo con el documento API, debe haber un accesorio de consulta de búsqueda que mencioné en mi código, pero la búsqueda no parece estar funcionando.

El documento API no explica cómo implementarlo y los ejemplos disponibles en línea no parecen funcionar en el espacio aislado de código.

El único artículo disponible que parece explicar la búsqueda tiene un código incorrecto (accesorios duplicados): https://frugalisminds.com/how-to-create-react-sortable-tree/

Documento API: https://www.npmjs.com/package/react-sortable-tree

A continuación se muestra el código:

 import React, { Component } from "react"; import SortableTree from "react-sortable-tree"; import "react-sortable-tree/style.css"; export default class Tree extends Component { constructor(props) { super(props); this.state = { treeData: [ { title: "Chicken", children: [{ title: "Egg" }] }, { title: "Fish", children: [{ title: "fingerline" }] }, ], searchString: "" }; } handleSearchOnChange = e => { this.setState({ searchString: e.target.value, }); }; render() { return ( <div style={{ height: 400 }}> <input type="search" onChange={this.handleSearchOnChange} className="form-control" /> <SortableTree searchQuery={this.state.searchString} treeData={this.state.treeData} onChange={treeData => this.setState([...treeData])} isVirtualized={false} /> </div> ); } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

falta un searchFocusOffset para resaltar el elemento encontrado y un método de búsqueda que se puede definir de forma personalizada dentro del método de procesamiento de la siguiente manera:

 import React, { Component } from "react"; import SortableTree from "react-sortable-tree"; import "react-sortable-tree/style.css"; // This only needs to be imported once in your app export default class Tree extends Component { constructor(props) { super(props); this.state = { treeData: [ { title: "Chicken", children: [{ title: "Egg" }] }, { title: "Fish", children: [{ title: "fingerline" }] }, ], searchString: "" }; } render() { // Case insensitive search of `node.title` const customSearchMethod = ({ node, searchQuery }) => searchQuery && node.title.toLowerCase().indexOf(searchQuery.toLowerCase()) > -1; return ( <div style={{ height: 400 }}> <input type="search" onChange={event => this.setState({ searchString: event.target.value })} className="form-control" /> <SortableTree searchMethod={customSearchMethod} searchQuery={this.state.searchString} searchFocusOffset={0} treeData={this.state.treeData} onChange={treeData => this.setState([...treeData])} isVirtualized={false} /> </div> ); } }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!