Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

227
Vistas
How do i hide the currency symbol when there is no input?

So i am making a create product page. The items were product name, product price, product description. There are gonna be times where user doesnt want to input any price on their product just yet. In that case i dont want it to show currency with the value 0 on the page. Is there any way to hide the currency? thank you

const [price, setPrice] = useState();

  const formatter = new Intl.NumberFormat("id-ID", {
    style: "currency",
    currency: "IDR",
  });

<p className="card-text">{formatter.format(item.price)}</p>
almost 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can add a condition to check the empty value of item.price on your JSX like below

<p className="card-text">{Boolean(item.price) && formatter.format(item.price)}</p>

If you want to reuse that formatter for other values, I'd suggest you introduce a function

const formatCurrency = (priceValue) => {
   if(!priceValue) {
     return '';
   }

   return new Intl.NumberFormat("id-ID", {
    style: "currency",
    currency: "IDR",
  });
}

<p className="card-text">{formatCurrency(item.price)}</p>
almost 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda