Akila

Akila

  • NA
  • 216
  • 34.1k

toast message when state change react

May 10 2022 4:43 AM

Hi,

I want to show toast messge when state change.i cant use toast in useeffect its rerendering .

  useLayoutEffect(() => {

    getData({})

  }, [filteredDataSource]);

when filteredDatasource update toast will appear so i add like this.

  useLayoutEffect(() => {

    getData({})

    toast.show("new notification", {

        type: "success",

        placement: "top",

        duration: 2000,

        animationType: "slide-in",

        textStyle:'color:#fff'

      });

  }, [filteredDataSource]);

but it has error - TypeError: undefined is not a function (near '...toast.show...')

can anyone solve this


Answers (1)