Q. What is the correct syntax to pass a function as a prop?

  • (A) <MyComp func='doSomething' />
  • (B) <MyComp func={doSomething} />
  • (C) <MyComp func={doSomething()} />
  • (D) <MyComp func=doSomething />
πŸ’¬ Discuss
βœ… Correct Answer: (B) <MyComp func={doSomething} />
Explanation: Functions are passed as props using curly braces without invoking them.
Explanation by: Mr. Dubey
Functions are passed as props using curly braces without invoking them.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
134
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
96%
Success Rate