warning: received `true` for a non-boolean attribute `exact`. if you want to write it to the dom, pass a string instead: exact="true" or exact={value.tostring()}.
- Published
- Reading time
- 1 min read
- Length
- 299 words
On this page
What does "warning: received `true` for a non-boolean attribute `exact`. if you want to write it to the dom, pass a string instead: exact="true" or exact={value.tostring()}." mean?#
If you are a web developer, you might have seen the above warning in your console. It usually happens when you are working with React or other JavaScript frameworks & libraries. The warning is indicating that you are trying to pass a boolean value to an attribute that is expecting a string value.
This warning is important because if you ignore it, you might run into unexpected behavior on your website. For example, if you try to render a component with an exact value of “true”, it might not work as expected because the attribute is not set to a string value.
How to fix the warning?#
The warning message tells you how to fix the issue. Instead of passing a boolean value, you should pass a string value. You can do this by using quotes around the value, like this:
<MyComponent exact="true" />Alternatively, you can use JavaScript to convert the boolean value to a string:
<MyComponent exact={true.toString()} />This will ensure that the attribute is set to a string value and that you don’t get any warnings in your console.
Conclusion#
When working with web development, it is important to pay attention to warnings in your console. The "warning: received `true` for a non-boolean attribute `exact`. if you want to write it to the dom, pass a string instead: exact="true" or exact={value.tostring()}." warning is indicating that you are passing a boolean value to an attribute that is expecting a string value. To fix the issue, you can either pass a string value directly or use JavaScript to convert the boolean value to a string.