score:170
Accepted answer
Boolean Value: { ipsumText.toString() }
or
Boolean Value: { String(ipsumText) }
or
Boolean Value: { '' + ipsumText }
or
{`Boolean Value: ${ipsumText}`}
or
Boolean Value: { JSON.stringify(ipsumText) }
I prefer the second option. Universal, fast, works for all primitive types: Boolean( smth )
, Number( smth )
.
score:-1
<select>
<option value={row.feature_product ? true: true || row.feature_product ? false: false}>
{`${row.feature_product}`}
</option>
<option value={row.feature_product ? false: true || row.feature_product ? true: false}>
{`${row.feature_product ? false: true}` || `${row.feature_product ? true: false}`}
</option>
</select>
score:2
You can convert boolean value to string, concatenating it with empty string:
var ipsumText = true;
ReactDOM.render(
<div>
Boolean Value: {ipsumText + ''}
</div>,
document.getElementById('impl')
);
Or you can do it, when assigning bool
value to variable:
var ipsumText = true + '';
ReactDOM.render(
<div>
Boolean Value: {ipsumText}
</div>,
document.getElementById('impl')
);
If your variable can have not boolean value, you should convert it to boolean:
// `ipsumText` variable is `true` now.
var ipsumText = !!'text';
Source: stackoverflow.com
Related Query
- Cannot render boolean value in JSX?
- why we cannot pass boolean value as props in React , it always demands string to be passed in my code
- Cannot set useState hook value to opposite boolean
- Boolean checkbox value in JSX doesn't work
- Reactjs render JSX with dynamic text value
- Cannot use boolean in JSX attribute
- Cannot seem to style my component via boolean value
- How do I get cookies and conditionally render JSX component based on value
- failed to get state value in render of jsx
- React event target value from jsx element does not get bind to state and json array (Type error cannot read the properties of undefined )
- How to render the checked or unchecked checkbox based on some boolean value from an api in react?
- Render component in jsx based on async function returning boolean
- How to render a boolean value in an array with condition
- Cannot render value of props from redux state
- Cannot use JSX unless the '--jsx' flag is provided
- Tag Error: React JSX Style Tag Error on Render
- Component cannot be used as a JSX component. Its return type 'Element[]' is not a valid JSX element
- Cannot convert object to primitive value error in react application?
- How to render (print) JSX as String?
- Babel error: JSX value should be either an expression or a quoted JSX text
- React-MobX Error: The 'decorators' plugin requires a 'decoratorsBeforeExport' option, whose value must be a boolean
- how to render multiple children without JSX
- Assign a value to a variable in JSX for ReactJS
- Spying on React functional component method with jest and enzyme; Cannot spyOn on a primitive value
- useState with boolean value in react
- How to render a string with JSX in React
- Cannot change value of select element using enzyme
- How to return an empty jsx element from the render function in react?
- Cannot update during an existing state transition (such as within `render`). Render methods should be a pure function of props and state. in Index.js
- Get React.refs DOM node width after render and trigger a re-render only if width has value has changed
More Query from same tag
- How can I set a logical operator between two spread operators in ES6
- ReactJS rendering issue
- How to style a reusable component including two divs, only for one of two parent components?
- How to know a react link component has been clicked
- Ternary in jsx to add selected attribute to option
- Material UI dropdown showing inappropriate height
- UseEffect hook not updating prop correctly
- UseEffect is thrown when it shouldn't be
- React TypeError: Cannot read property 'map' of undefined
- Can't perform a React state update on an unmounted component and states are not getting updated
- Apollo Client Cache vs. Redux
- useState hook - state gets lost i.e. resets to initial value
- Test that a component does not render when passed a certain prop value with enzyme
- How to add new input row to table on click?
- How to get the length of the text inside the React component
- In Redux, how do I update only part of a state object?
- How to get the HTML output from a rendered component
- Module parse error when trying to load background image in a css element
- Google Authentication using firebase in reactjs is not working
- How to save the name of object in array object?
- React JS 'propTypes' validators running twice
- Displaying Nested Objects in React after fetching the data from an api?
- ReactJS State not getting updated
- All TableRows are rerendered each time a row is selected with React and material-ui
- React useState with Array of objects
- Yup validate array of objects contains at most one object where property = value
- products is not a function after destructuring
- How do I use React 15.5 with TypeScript?
- How import object from external JS file in React JS using web pack
- Try to map through an enum in TS with Object.entries<T>(Enum).map(), but only works with string based enums?