0

---It is Grandchild value that i want to send child component then Parent component with typescript React ----

const [mapDestinationfilter, setmapDestinationfilter] = React.useState<any[]>([]);

  const onChange = (e) => {
    const value = e.target.value
    const Destinationfilter = mapdata?.filter(el => {
      return el.price.amount < value
    })
    setmapDestinationfilter(Destinationfilter)

  }

how can I pass this mapDestinationfilter to child component then to parent component with typescript React hooks ?

skyboyer
  • 22,209
  • 7
  • 57
  • 64
Farhad
  • 31
  • 1
  • 3
  • const [mapDestinationfilter, setmapDestinationfilter] = React.useState([]); initialize in child component and pass as props into grandchild – 欧阳斌 Sep 16 '21 at 08:47
  • i initialize as this const newfilteredData = React.useCallback(() => { updateName(); }, []) . then sending data to grandChild compenent updateName={updateName} – Farhad Sep 16 '21 at 08:52
  • also it is my grandchild code interface IProps { updateName: (arg: any) => void} {updateName }: IProps updateName(mapDestinationfilter) – Farhad Sep 16 '21 at 08:54
  • But this code does not work @欧阳斌 – Farhad Sep 16 '21 at 08:55
  • @欧阳斌 when i do console.log to updateName in child component it shows as the below mobileFilterdData => { setmapDestinationfilter(mobileFilterdData); } – Farhad Sep 16 '21 at 08:58

0 Answers0