React Native: check which checkbox is selected within a checkbox list

Asked

Viewed 651 times

0

Hello, I have the following problem I have a list of checkbox, and would like to check which checkbox is selected after clicking the button.

import React, {
    Component
} from 'react';

import {
    Platform,
    StyleSheet,
    Text,
    View,
    ScrollView,
    CheckBox
} from 'react-native';
import Checkbox from 'react-native-custom-checkbox';

export default class App extends Component {
    constructor(props) {
        super(props);
        this.state = {
            checked: false,
            check: []
        };
    }

    _myFunction(value, name, checked) {
        console.log("Log:  " + value, checked);
    };

    clickButton() {

    }

    render() {

        let checkboxes = [];

        for (let i = 0; i < 5; i++) {
            checkboxes.push( <
                View >
                <
                Checkbox

                name = 'checkbox2'
                checked = {
                    false
                }
                size = {
                    30
                }
                style = {
                    {
                        backgroundColor: '#f2f2f2',
                        color: 'blue',
                        borderRadius: 5
                    }
                }
                onChange = {
                    (name, checked) => this._myFunction(name, i, checked)
                }
                /> <
                /View>
            );
        }

        return ( <
            View >
            <
            Button onPress = {
                () => this.clickButton()
            } > < /Button> {
                checkboxes
            }

            <
            /View>
        );

    }

}

Could someone help me

1 answer

1


  • 1

    Cara valeu gave to do in Act Native helped me a lot

Browser other questions tagged

You are not signed in. Login or sign up in order to post.