Let's review the rules of React Hooks, and how you can fix the "Hooks can only be called inside the body of a function component." Let's take a look at how you can fix this common error in React. React error boundaries allow you to prevent your React application from completely crashing in the event of an error in your code.
Think of context as a component in your tree that can provide props directly to any child below it.
By using context here, we can create a generic ModalCloseButton component that can be used anywhere within a modal to close the modal.