Why after wrapping function that return object in useMemo I get warning about non function?

alexDevAlex33

I have this function and pass it to component but after useMemo wrapper it says me that modalComponentsData is not function

  const modalComponentsData = useMemo(() => {
    return [
      { name: 'name', placeholder: 'Company name' },
    ]
  }, [])
Yury Tarabanko

useMemo calls the function it gets to produce the value. You need useCallback.

  const modalComponentsData = useCallback(() => {
    return [
      { name: 'name', placeholder: 'Company name' },
    ]
  }, [])

Or

  const modalComponentsData = useMemo(() => () => {
    return [
      { name: 'name', placeholder: 'Company name' },
    ]
  }, [])

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

why is this warning ( no return , in function returning non-void)?

From Dev

Update object after function return

From Java

Typescript | Warning about Missing Return Type of function, ESLint

From Dev

Why doesn't this object get set to NULL after the function call?

From Dev

What is causing the warning "no return, in function returning non-void"?

From Dev

Return non-returning function from Promise results in Warning

From Dev

Get a warning when I overwrite a function in Julia?

From Dev

Why don't I get a warning when I declare a variable with same name in a macro that already exists in a function?

From Dev

Odd warning about iconv() function

From Dev

Trying to get property of non-object with if function

From Dev

why in this code would I be getting "Unexpected non-void return value in void function"

From Dev

Wrapping non serializable type with serializable function

From Dev

warning: ‘noreturn’ function does return

From Dev

Why Cant I return Void directly in a function

From Dev

I'm returning non-named object from a function. Why RVO still kicks in?

From Dev

Why can I call non-static function without declaring the class object?

From Dev

Get object after outside function call

From Dev

Why can I call a function before defining it, with only a warning?

From Dev

Why I'm getting clang warning: no previous prototype for function 'diff'

From Dev

Why am i allowed to pass an object of the bounding type of a generic type to a function, but not allowed to return it?

From Dev

I cant get the return function working

From Dev

Why do I get an old object when creating a new object using let and new in a function within a service?

From Dev

How to return nil object in non void function - swift 2.1?

From Dev

Why is my function declaration wrapping to 2 lines?

From Dev

Why can't I instantiate an object in a function

From Dev

How can I get a v8 function to return a c++ object?

From Dev

Cannot return the address of a cell range from one function to another, I get an 'object required' error

From Dev

Why do I get a message saying "Object is not a function" when I try to do an apply?

From Dev

Why do I get an error message of NoneType object is not callable when I try to call this function?

Related Related

  1. 1

    why is this warning ( no return , in function returning non-void)?

  2. 2

    Update object after function return

  3. 3

    Typescript | Warning about Missing Return Type of function, ESLint

  4. 4

    Why doesn't this object get set to NULL after the function call?

  5. 5

    What is causing the warning "no return, in function returning non-void"?

  6. 6

    Return non-returning function from Promise results in Warning

  7. 7

    Get a warning when I overwrite a function in Julia?

  8. 8

    Why don't I get a warning when I declare a variable with same name in a macro that already exists in a function?

  9. 9

    Odd warning about iconv() function

  10. 10

    Trying to get property of non-object with if function

  11. 11

    why in this code would I be getting "Unexpected non-void return value in void function"

  12. 12

    Wrapping non serializable type with serializable function

  13. 13

    warning: ‘noreturn’ function does return

  14. 14

    Why Cant I return Void directly in a function

  15. 15

    I'm returning non-named object from a function. Why RVO still kicks in?

  16. 16

    Why can I call non-static function without declaring the class object?

  17. 17

    Get object after outside function call

  18. 18

    Why can I call a function before defining it, with only a warning?

  19. 19

    Why I'm getting clang warning: no previous prototype for function 'diff'

  20. 20

    Why am i allowed to pass an object of the bounding type of a generic type to a function, but not allowed to return it?

  21. 21

    I cant get the return function working

  22. 22

    Why do I get an old object when creating a new object using let and new in a function within a service?

  23. 23

    How to return nil object in non void function - swift 2.1?

  24. 24

    Why is my function declaration wrapping to 2 lines?

  25. 25

    Why can't I instantiate an object in a function

  26. 26

    How can I get a v8 function to return a c++ object?

  27. 27

    Cannot return the address of a cell range from one function to another, I get an 'object required' error

  28. 28

    Why do I get a message saying "Object is not a function" when I try to do an apply?

  29. 29

    Why do I get an error message of NoneType object is not callable when I try to call this function?

HotTag

Archive