---
# System prepended metadata

title: codigo back button

---

# codigo back button
// Dependencies
```import React, {useCallback} from 'react';
import {
  TouchableOpacity as TouchableOpacityNative,
  Platform,
} from 'react-native';
import {TouchableOpacity as TouchableOpacityGesture} from 'react-native-gesture-handler';

// Commons
import {Normalize} from '../../../style/normalice';

// Assets
import ArrowLeftIcon from '../../../assets/icons/arrow-left.svg';

// issue TouchableOpacity https://github.com/facebook/react-native/issues/14536

function BackButton({navigation = null, onPress = null}) {
  const onPressBack = useCallback(() => {
    if (onPress) {
      onPress();
    }
    if (navigation && !onPress) {
      navigation.goBack();
    }
  }, [navigation, onPress]);
  const renderIcon = useCallback(
    () => <ArrowLeftIcon width={Normalize(24)} height={Normalize(24)} />,
    [],
  );
  return Platform.OS === 'ios' ? (
    <TouchableOpacityNative onPress={onPressBack}>
      {renderIcon()}
    </TouchableOpacityNative>
  ) : (
    <TouchableOpacityGesture onPress={onPressBack}>
      {renderIcon()}
    </TouchableOpacityGesture>
  );
}

export default BackButton;
