Search code examples
reactjsreact-routercomponentsnavbar

Bad practice to embed a React component in Navbar?


Is it bad practice to embed a Results page component in the Navbar component since it has the search bar in it and I could pass the input value as a prop to Results component in the JSX? But is this good practice as I am including a major component in the Navbar? Currently, I am using the router, useNavigation, useParams, methods to detect change but it is introducing unnecessary complexity.


Solution

  • It is Okay to pass props from parent to child component.

    if you think it is not good practice then use Context API

    or else use Global State Management library like redux

    but for Simple Application I suggest that to pass props from Parent to child.