How to add checkbox in react native?, how to create checkbox in react native, how to create a checkbox in react native, How to add checkbox in react native

How to add checkbox in react native?

In this tutorials we will use a package named @react-native-community/checkbox to add checkboxes in react native. So follow the below setups:-

1) Install the @react-native-community/checkbox package like below in your application

yarn add @react-native-community/checkbox

or

npm install @react-native-community/checkbox --save

On iOS, install cocoapods:

npx pod-install

2) Link the module in your application


react-native link @react-native-community/checkbox

3) Import the package

import CheckBox from '@react-native-community/checkbox';

4) Example
follow below example to use checkbox


import React , {useState } from 'react';
import CheckBox from '@react-native-community/checkbox';

 const [toggleCheckBox, setToggleCheckBox] = useState(false)

function AddContactScreen ({navigation}){

  return (
	    <View>
         <CheckBox
          disabled={false}
          value={toggleCheckBox}
          onValueChange={(newValue) => setToggleCheckBox(newValue)}
        />

	    </View>
	  );
   }

export default AddContactScreen;

Post Created 49

Leave a Reply

Related Posts

Begin typing your search above and press enter to search. Press ESC to cancel.

Back To Top