I Am Getting This Error Functions are not valid as a React child. This may happen if you return a Component instead of from render. Or maybe you meant to call this function rather than return it
And
Matched leaf route at location "/" does not have an element. This means it will render an with a null value by default resulting in an "empty" page.
Below picture is the index.ts code in the change-accouont folder in the pages folder. I want to open different pages here based on the parameters in the URL:
But when i enter the url, will show the below error.
Below is the DeleteAccountPage code:
Below picture is the createDeleteAccountPage code:
How to fix this error in react?
2
Answers
if
DeleteAccountPage
andChangeAccountPage
are Component you need change your code to :for return a component like DeleteAccountPage
You are not returning anything in your code blocks. You can do something like:
However you need to be careful how you use this code. Based on what you shared you’d need something like:
This is arguably bad practice. Instead you should use component composition:
This way to use this component you just need: