Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

how to change syntax Typescript to javascript React native

$
0
0

i'm building Raect Native with Expo, trying to make custom dropdown and i find and article wit an awesome expiation how to do that here

the code written with typeScript syntax, but my project using a javaScript syntax so

  1. how can i change the code syntax's to work on my project?
  2. can use both Typescript and javascript on one project (so build the reusable component with Typescript)?
interface Props {  label: string;}const Dropdown: FC<Props> = ({ label }) => {  const [visible, setVisible] = useState(false);  const toggleDropdown = () => {    setVisible(!visible);  };  const renderDropdown = () => {    if (visible) {      return (<Text style={styles.dropdown}>            This is where the dropdown will be rendered.</Text>      );    }  };  return (<TouchableOpacity      style={styles.button}      onPress={toggleDropdown}>      {renderDropdown()}<Text style={styles.buttonText}>{label}</Text><Icon type='font-awesome' name='chevron-down'/></TouchableOpacity>  );}

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>