Skip to content
Advertisement

defining a function to pass it as props, but I get a compiling error

I have a react component that is trying to pass a function to another component, the problem is that I’m not being able to define the function, it throws a compiling error

JavaScript

What am I missing?

Rafael

Advertisement

Answer

You declared component as functional, but trying to create a class method.

You should either use class component:

JavaScript

with 2 methods: createActivity and render.

Or declare your function and assign to constant

JavaScript

but use it without this:

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