Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to return values from function - React native

How to return a boolean value from react native function?

like image 906
Anju Avatar asked Jul 04 '17 13:07

Anju


People also ask

What is the use of return function in React Native?

The render method returns a description of what the DOM should look like, and then React efficiently updates the real DOM to match." Render is that what exactly you want to trigger multiple times. Return is that which u want to Display.

How do I export a functional component in React?

Use named exports to export a component in React, e.g. export function Button() {} . The exported component can be imported by using a named import as import {Button} from './another-file. js' . You can use as many named exports as necessary in a file.


1 Answers

it can be accomplish like this:

export function isJson(str) {
  try {
    JSON.parse(str);
  } catch (e) {
    return false;
  }
  return true;
}

This function checks whether provided value is valid JSON or not.

like image 189
Jigar Shah Avatar answered Sep 24 '22 10:09

Jigar Shah