Skip to content
Advertisement

React – CheckboxTree filter

So i am using this package “react-checkbox-tree” to make a checkbox, but since this is made on classes components and i need to do it with functions and hooks, this is being a bit tricky to my actual skills.

JavaScript
  • My first problem is that when i search for the parent, i only get the last children of the array for some reason.

  • The Second is that when i use the backspace button, the filter stops working until i clean every char.

I made a codesandbox to help you guys to understand the problems: https://codesandbox.io/s/checkboxtree-6gu60

This is the example on with classes: https://github.com/jakezatecky/react-checkbox-tree/blob/master/examples/src/js/FilterExample.js

Tks in advance!

Advertisement

Answer

For your second problem, I solved it by passing through onKeyDown as well as onChange from my search input:

JavaScript

which calls

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement