Skip to content
the poor coder

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()}.

Poor Man
Published
Reading time
1 min read
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:

Text
<MyComponent exact="true" />

Alternatively, you can use JavaScript to convert the boolean value to a string:

Text
<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.

Keep going

2023

how to sort an array

How to Sort an Array If you have an array and you want to order its elements in a specific way, you need to use a sorting algorithm. There are several sorting algorithms available, but two of the most commonly used are…

javascript2 min read
2023

jquery mobile or desktop

jQuery Mobile or Desktop? As a web developer, I have had some experience with both jQuery Mobile and jQuery Desktop. Both frameworks have their pros and cons, and which one to use really depends on the specific project…

javascript1 min read
2023

node.js folder structure

Node.js Folder Structure If you are new to Node.js, it can be daunting to create a folder structure that will work for your project. The structure you choose will depend on the size and complexity of your project. Here…

javascript1 min read
ESC