You could check for trimmed string:

{this.props.description.name.trim() == ""}

This trims the string (which removes whitespace and newlines) and then check is if it's an empty string. Here's a CodePen demonstration.

Answer from Andrew Li on Stack Overflow
🌐
Bobby Hadz
bobbyhadz.com › blog › react-check-if-array-is-empty
Check if an Array or a String is Empty in React | bobbyhadz
To check if a string is empty in React, access its length property and check if it's equal to 0.
🌐
CoreUI
coreui.io › answers › how-to-check-if-a-string-is-empty-in-javascript
How to check if a string is empty in JavaScript · CoreUI
September 24, 2025 - For a more comprehensive check including null and undefined, use !text || text.length === 0. The strict comparison === 0 is preferred over == 0 to avoid type coercion issues and ensure precise empty string detection. ... Follow Łukasz Holeczek on GitHub Connect with Łukasz Holeczek on LinkedIn Follow Łukasz Holeczek on X (Twitter) Łukasz Holeczek, Founder of CoreUI, is a seasoned Fullstack Developer and entrepreneur with over 25 years of experience. As the lead developer for all JavaScript, React.js, and Vue.js products at CoreUI, they specialize in creating open-source solutions that empower developers to build better and more accessible user interfaces.
🌐
freeCodeCamp
freecodecamp.org › news › javascript-check-empty-string-checking-null-or-empty-in-js
JavaScript Check Empty String – Checking Null or Empty in JS
November 7, 2024 - In this first method, we will check for the length of the string by adding the length property. We'll check if the length is equal to 0. If it’s equal to zero, it means that the string is empty, as we can see below:
🌐
W3docs
w3docs.com › javascript
How to Check for Empty/Undefined/Null String in JavaScript
When the string is not null or undefined, and you intend to check for an empty one, you can use the length property of the string prototype, as follows:
🌐
GitHub
github.com › facebook › react-native › issues › 35002
Empty string without <Text> component does not cause error / crash · Issue #35002 · facebook/react-native
August 5, 2022 - Hi there, first of all, thanks so much for your continued work on React Native, amazing project! 🙌 · Recently I tried adding an empty string (both literal '' and a variable with the same value) outside of a <Text> component and I did not experience a crash like I was expecting (I was expecting it to show me the Text strings must be rendered within a <Text> component. error as documented in many issues in this repo and elsewhere on the Internet).
Published   Oct 17, 2022
Find elsewhere
🌐
GitHub
github.com › facebook › react-native › issues › 29980
Conditional rendering against an empty string causes application to crash with cryptic error message · Issue #29980 · facebook/react-native
August 3, 2020 - If it turns out to be a React problem, I can file an issue over there instead; just let me know. When using conditional rendering in JSX with the && operator, using a variable containing the empty string ("") as the render condition causes React Native to blow up with the following error message:
Published   Sep 18, 2020
🌐
DEV Community
dev.to › trinityyi › tip-react-conditional-classname-empty-strings-and-null-37be
Tip: React conditional className, empty strings and null - DEV Community
November 13, 2022 - However, if you carefully inspect the HTML, you will notice that the first one will render <div class>Hi</div> whereas the second one will render <div>Hi</div>. This kind of markup (an attribute being present but without value) is rather uncommon and you'd rarely ever see something like that without React. This subtle difference is quite important and might be the root of a lot of problems, especially when writing CSS selectors for elements with/without any classes (e.g. [class]/:not([class])). Therefore, you should prefer null when you don't want to add a className to an element, instead of an empty string.
🌐
ThatSoftwareDude.com
thatsoftwaredude.com › content › 8774 › what-is-the-best-way-to-check-for-an-empty-string-in-javascript
The Best Way to Check for an Empty String in JavaScript - ThatSoftwareDude.com
August 23, 2024 - Want to check if a string is empty in JavaScript? There are several ways to do it, but not all are equally readable, safe, or performant. In...
🌐
Reddit
reddit.com › r/reactjs › use empty string, null or remove empty property in api request/response?
r/reactjs on Reddit: Use empty string, null or remove empty property in API request/response?
January 31, 2023 -

we had an argue about this on our team, I wonder what approach should we consider? what is the better?

We have a user interface like this:

interface User {
name:string;
family?:string;
age:number;

family name is optional, so our backend developer sends us this json data for those users that didnt filled the family:

{name: "john",
family:"",
age:18
}

and in another object's case they sends null for the optional props...

We have been confused with this not having a solid convention from the backend team! what approach is the better? I think the right way is just removing optional property from the json data instead of setting it to null or "" empty string, I mean just dont add that!

🌐
Sentry
sentry.io › sentry answers › javascript › how do i check for an empty/undefined/null string in javascript?
How do I Check for an Empty/Undefined/Null String in JavaScript? | Sentry
To check that a value is not an empty string, null, or undefined, you can create a custom function that returns true if a value is null, undefined, or an empty string and false for all other falsy values and truthy values:
🌐
Medium
medium.com › @glasshost › how-to-check-if-an-input-is-empty-in-react-78d0b0d945bb
How to Check if an Input is Empty in React | by Glasshost | Medium
May 4, 2023 - In the `handleSubmit` function, we check if the `inputValue` is empty by using the `trim` method to remove any whitespace characters. Another way of checking if an input is empty in React is by using refs.
🌐
freeCodeCamp
freecodecamp.org › news › check-if-string-is-empty-or-null-javascript
How to Check if a String is Empty or Null in JavaScript – JS Tutorial
November 7, 2024 - In this example, we're checking whether the str variable is a string and whether its length is zero. If it is, then we know that it's an empty string. If the str variable is null, then we know that it's a null string.
🌐
Tutorial Republic
tutorialrepublic.com › faq › how-to-check-for-an-empty-string-in-javascript.php
How to Check for an Empty String in JavaScript
The comparsion str === "" will only return true if the data type of the value is string and it is not empty, otherwise return false as demonstrated in the following example:
Top answer
1 of 16
5116

Empty string, undefined, null, ...

To check for a truthy value:

if (strValue) {
    // strValue was non-empty string, true, 42, Infinity, [], ...
}

To check for a falsy value:

if (!strValue) {
    // strValue was empty string, false, 0, null, undefined, ...
}

Empty string (only!)

To check for exactly an empty string, compare for strict equality against "" using the === operator:

if (strValue === "") {
    // strValue was empty string
}

To check for not an empty string strictly, use the !== operator:

if (strValue !== "") {
    // strValue was not an empty string
}
2 of 16
1448

For checking if a variable is falsey or if it has length attribute equal to zero (which for a string, means it is empty), I use:

function isEmpty(str) {
    return (!str || str.length === 0 );
}

(Note that strings aren't the only variables with a length attribute, arrays have them as well, for example.)

Alternativaly, you can use the (not so) newly optional chaining and arrow functions to simplify:

const isEmpty = (str) => (!str?.length);

It will check the length, returning undefined in case of a nullish value, without throwing an error. In the case of an empty value, zero is falsy and the result is still valid.

For checking if a variable is falsey or if the string only contains whitespace or is empty, I use:

function isBlank(str) {
    return (!str || /^\s*$/.test(str));
}

If you want, you can monkey-patch the String prototype like this:

String.prototype.isEmpty = function() {
    // This doesn't work the same way as the isEmpty function used 
    // in the first example, it will return true for strings containing only whitespace
    return (this.length === 0 || !this.trim());
};
console.log("example".isEmpty());

Note that monkey-patching built-in types are controversial, as it can break code that depends on the existing structure of built-in types, for whatever reason.

🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-check-empty-undefined-null-string-in-javascript
How to Check empty/undefined/null String in JavaScript? - GeeksforGeeks
July 11, 2025 - Empty strings contain no characters, while null strings have no value assigned. Checking for an empty, undefined, or null string in JavaScript involves verifying if the string is falsy or has a length of zero.