0

I am using checkbox from react-native-element

When i check the box it dose not display checked how can i display it ? here is my code

 <View>
                    <FlatList data={all_national_number}
                        keyExtractor={(item, index) => index.toString()}
                        renderItem={({ item }) =>
                            <CheckBox

                                title={item} 
                                uncheckedIcon={<Image source={require('../../assets/unchecked.png')} />}
                           checkedIcon={<Image source={require('../../assets/checked.jpg')} />}

                                onPress={() => this._onSelect(item)}>
                            </CheckBox>

                        }>
                    </FlatList>
                    </View>
1

2 Answers 2

0

It is not showing because you are missing a property called checked which should be either true or false. So, ideally your method this._onSelect(item)} should contain logic to alter the checked status.

Something on the lines of

onSelect = (item) => {
this.setState({ isChecked: true})
}

and in your checkbox, you need to add one more prop that is checked={this.state.isChecked}

Hope it helps :)

Sign up to request clarification or add additional context in comments.

Comments

0

You need to add the checked property on the checkbox

<CheckBox
  title='Click Here'
  checked={this.state.checked}
/>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.