Skip to main content
deleted 13 characters in body
Source Link

I've written this Card component which is composed of thumbnail image, name, symbol, total_volume, current_price, and price_change_percentage_24h.

enter image description here

I want to refactor my renderPriceChange function since it's using the same pattern.

const renderPriceChange = (price) => {
  if (price > 0) {
    return (
      <Text style={styles.rise}>
        <AntDesign name='caretup' color='#03AE9D' size={10} />{' '}
        {percentageFormat(item.price_change_percentage_24h)}%
      </Text>
    );
  } else {
    return (
      <Text style={styles.drop}>
        <AntDesign name='caretdown' color='#fb2c33' size={10} />{' '}
        {percentageFormat(item.price_change_percentage_24h)}%
      </Text>
    );
  }
};

How to make it look cleaner with smart and less code? PRs welcome!

I've written this Card component which is composed of thumbnail image, name, symbol, total_volume, current_price, and price_change_percentage_24h.

enter image description here

I want to refactor my renderPriceChange function since it's using the same pattern.

const renderPriceChange = (price) => {
  if (price > 0) {
    return (
      <Text style={styles.rise}>
        <AntDesign name='caretup' color='#03AE9D' size={10} />{' '}
        {percentageFormat(item.price_change_percentage_24h)}%
      </Text>
    );
  } else {
    return (
      <Text style={styles.drop}>
        <AntDesign name='caretdown' color='#fb2c33' size={10} />{' '}
        {percentageFormat(item.price_change_percentage_24h)}%
      </Text>
    );
  }
};

How to make it look cleaner with smart and less code? PRs welcome!

I've written this Card component which is composed of thumbnail image, name, symbol, total_volume, current_price, and price_change_percentage_24h.

enter image description here

I want to refactor my renderPriceChange function since it's using the same pattern.

const renderPriceChange = (price) => {
  if (price > 0) {
    return (
      <Text style={styles.rise}>
        <AntDesign name='caretup' color='#03AE9D' size={10} />{' '}
        {percentageFormat(item.price_change_percentage_24h)}%
      </Text>
    );
  } else {
    return (
      <Text style={styles.drop}>
        <AntDesign name='caretdown' color='#fb2c33' size={10} />{' '}
        {percentageFormat(item.price_change_percentage_24h)}%
      </Text>
    );
  }
};

How to make it look cleaner with smart and less code?

added 39 characters in body; edited title
Source Link
200_success
  • 145.6k
  • 22
  • 191
  • 481

React component to render price change

I've written this Card componentCard component which composesis composed of thumbnail image, name, symbol, total_volume, current_price, and price_change_percentage_24h.

enter image description here

I want to refactor my renderPriceChange function since it's using the same pattern.

const renderPriceChange = (price) => {
  if (price > 0) {
    return (
      <Text style={styles.rise}>
        <AntDesign name='caretup' color='#03AE9D' size={10} />{' '}
        {percentageFormat(item.price_change_percentage_24h)}%
      </Text>
    );
  } else {
    return (
      <Text style={styles.drop}>
        <AntDesign name='caretdown' color='#fb2c33' size={10} />{' '}
        {percentageFormat(item.price_change_percentage_24h)}%
      </Text>
    );
  }
};

How to make it look cleaner with smart and less code? PRs welcome!

React component render price change

I've written this Card component which composes of thumbnail image, name, symbol, total_volume, current_price, and price_change_percentage_24h.

enter image description here

I want to refactor my renderPriceChange function since it's using the same pattern.

const renderPriceChange = (price) => {
  if (price > 0) {
    return (
      <Text style={styles.rise}>
        <AntDesign name='caretup' color='#03AE9D' size={10} />{' '}
        {percentageFormat(item.price_change_percentage_24h)}%
      </Text>
    );
  } else {
    return (
      <Text style={styles.drop}>
        <AntDesign name='caretdown' color='#fb2c33' size={10} />{' '}
        {percentageFormat(item.price_change_percentage_24h)}%
      </Text>
    );
  }
};

How to make it look cleaner with smart and less code? PRs welcome!

React component to render price change

I've written this Card component which is composed of thumbnail image, name, symbol, total_volume, current_price, and price_change_percentage_24h.

enter image description here

I want to refactor my renderPriceChange function since it's using the same pattern.

const renderPriceChange = (price) => {
  if (price > 0) {
    return (
      <Text style={styles.rise}>
        <AntDesign name='caretup' color='#03AE9D' size={10} />{' '}
        {percentageFormat(item.price_change_percentage_24h)}%
      </Text>
    );
  } else {
    return (
      <Text style={styles.drop}>
        <AntDesign name='caretdown' color='#fb2c33' size={10} />{' '}
        {percentageFormat(item.price_change_percentage_24h)}%
      </Text>
    );
  }
};

How to make it look cleaner with smart and less code? PRs welcome!

Source Link

React component render price change

I've written this Card component which composes of thumbnail image, name, symbol, total_volume, current_price, and price_change_percentage_24h.

enter image description here

I want to refactor my renderPriceChange function since it's using the same pattern.

const renderPriceChange = (price) => {
  if (price > 0) {
    return (
      <Text style={styles.rise}>
        <AntDesign name='caretup' color='#03AE9D' size={10} />{' '}
        {percentageFormat(item.price_change_percentage_24h)}%
      </Text>
    );
  } else {
    return (
      <Text style={styles.drop}>
        <AntDesign name='caretdown' color='#fb2c33' size={10} />{' '}
        {percentageFormat(item.price_change_percentage_24h)}%
      </Text>
    );
  }
};

How to make it look cleaner with smart and less code? PRs welcome!