I am developing a react component to display errors, success, and other messages.
The component takes the props type
and message
. Type determines the styling of the message, and message
is the content itself. I need to build this component to be scalable, and creating conditional rendering isn't feasible as the number of variables and functions needed would grow exponentially as the number of messages increased. I need a way to render only when required with changing props (such as a specific unknown error message).
For example, something like:
onClick={() => <Message type={req.body.errorType} message="Internal Server Error" />}
Is this even possible?
To my knowledge, I am not asking the same thing as other "Condition rendering" questions, as the answers to this, propose the very thing I am trying to steer clear of.
Edit: This was flagged as duplicate. If the person flagging would have read the sentence below the question, I preemptively explained how it wasn't a duplicate. The linked question was the one I read previously and DID not help.