Hi Friends 👋,

Welcome To Infinitbility! ❤️

To check data type in react native, use typeof keyword it will return type of data just we have to use this keyword before variable or data.

Let’s see short example to use typeof to get data type of value.

typeof "Hello";

Today, I’m going to show you How do I check data type in react native, as above mentioned, I’m going to use the above-mentioned typeof method.

Let’s start today’s tutorial how do you check data type in react native?

React native check data type example using typeof

Here, we will take example of string, number, boolean, object and undefined datatype.

import React, { useState, useEffect } from "react";
import { Text, View } from 'react-native';
export default function App() {

  useEffect(() => {
    console.log(typeof "Infinitbility");
    console.log(typeof 2);
    console.log(typeof true);
    console.log(typeof {id: 1});
    console.log(typeof undefined)
  }, []);

  return (
      <Text>{typeof "Infinitbility"}</Text>
      <Text>{typeof 2}</Text>
      <Text>{typeof true}</Text>
      <Text>{typeof {id: 1}}</Text>
      <Text>{typeof undefined}</Text>


I hope it helps you, All the best 👍.