Jon
Jon

Reputation: 509

Calling sibling function and scope

I want to know if I can call function1 from function2 or if I need to pass it down as props? I'm a bit confused because I am already passing props down via App.

function App(props) {
  function function1 {}
  function function2 {
    function1();
  }
}

Upvotes: 0

Views: 25

Answers (1)

Sobhan Jahanmard
Sobhan Jahanmard

Reputation: 890

Yes you can call. These functions are not components. You are confusing functional components with methods(functions defined in components).In your case App is the functional component or in short just a component and function1 & function2 are methods inside the App component. You have access to other methods that are defined in the same component as the said method.

Upvotes: 1

Related Questions