Boolean Value Not Rendered in MUI Typography Component #42641
Labels
component: Typography
The React component.
support: question
Community support but can be turned into an improvement
Steps to reproduce
Link to live example: (required)
CodeSend Box
Stackblitz
Steps to Reproduce:
Here is a code sample that demonstrates the issue:
Workaround:
A workaround is to convert the boolean value to a string before rendering it. This can be done using String(customValue) or customValue.toString() or JSON.stringify(customValue).
Example workaround:
Environment:
Additional Information:
This issue occurs because Typography (or its underlying rendering mechanism) does not implicitly convert boolean values to strings. Boolean values are not typically meant to be directly rendered in most UI components.
It would be helpful to provide an enhancement or a warning to developers to convert boolean values to strings before rendering.
Suggested Fix:
Enhance the Typography component to handle boolean values gracefully by converting them to their string representation before rendering. This can be implemented by checking the type of the children prop and converting boolean values as needed.
Screenshot
Current behavior
The Typography component does not render anything when a boolean value is provided directly.
Expected behavior
The Typography component should display the string representation of the boolean value, i.e., it should render true or false.
Context
When using the MUI (Material-UI) Typography component to render a boolean value directly within the component, the boolean value is not displayed on the UI. Instead of rendering true or false, nothing is shown. This issue can lead to confusion, especially when trying to debug UI elements that should display boolean states.
Your environment
npx @mui/envinfo
Search keywords: MUI Typography, Boolean value MUI Typography
The text was updated successfully, but these errors were encountered: