Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find variable item #12

Open
reactCoder1 opened this issue May 1, 2020 · 0 comments
Open

Can't find variable item #12

reactCoder1 opened this issue May 1, 2020 · 0 comments

Comments

@reactCoder1
Copy link

ReferenceError: can't find variable :item

MyCodeIs:....

`import React, { Component } from "react";

import { AppRegistry, View, Button, StyleSheet, Text } from 'react-native'
import LabelSelect from 'react-native-label-select'

class MyItskills extends Component {

constructor(props) {
    super(props);
    this.state = {
        arr: [{
            name: 'Microsoft Excel',
            isSelected: false,
            value: 1
        },
        {
            name: 'Microsoft Word',
            isSelected: false,
            value: 2
        },
        {
            name: 'Microsoft Access',
            isSelected: false,
            value: 3,
        },
        {
            name: 'Microsoft Office',
            isSelected: false,
            value: 4
        },
        {
            name: 'Microsoft Power Point',
            isSelected: false,
            value: 5
        },
        {
            name: 'Microsoft Exchage',
            isSelected: false,
            value: 6
        },
        {
            name: 'Micro Controls',
            isSelected: false,
            value: 7
        },
        {
            name: 'Micro Station',
            isSelected: false,
            value: 8
        },
        {
            name: 'Pcl',
            isSelected: false,
            value: 9
        },
        {
            name: 'Computers',
            isSelected: false,
            value: 10
        },
        {
            name: 'Emails',
            isSelected: false,
            value: 11
        }]
    };
    this.selectConfirm = this.selectConfirm.bind(this);
    this.deleteItem = this.deleteItem.bind(this);
}

selectConfirm(list) {
    let { arr } = this.state;
    for (let item of list) {
        let index = arr.findIndex(ele => ele === item);
        if (~index) arr[index].isSelected = true;
        else continue;
    }
    this.setState({ arr: arr });
}
deleteItem(item) {
    let {arr} = this.state;
    let index = arr.findIndex(a => a === item);
    arr[index].isSelected = false;
    this.setState({ arr: arr });
}

render() {
   

    return (
        <View style={styles.container}>
            <Text style={styles.text}>IT Skills</Text>
            <LabelSelect
                title="Checkbox"
                ref="select"
                style={styles.labelSelect}
                onConfirm={this.selectConfirm}>
                {this.state.arr.filter(item = item.isSelected).map((item, index) =>
                    <LabelSelect.Label
                        key={'label-' + index}
                        data={item}
                        onCancel={() => { this.deleteItem(item); }}
                    >
                        {item.name}
                    </LabelSelect.Label>
                )}
            </LabelSelect>
            {/* <Text style={styles.text}>Disable ItSkills</Text>
            <LabelSelect
                style={styles.LabelSelect}
                title="Checkbox"
                enable={false}
                onConfirm={this.selectConfirm}>
                {this.state.arr.filter(item => item.isSelected).map((item, index) =>
                    <LabelSelect.Label
                        key={'label-' + index}
                        data={item}
                        onCancel={() => { this.deleteItem(item); }}
                    ></LabelSelect.Label>
                )}
            </LabelSelect> */}


        </View>
    );
}

}
const styles = StyleSheet.create({
container:{
flex:1,
padding:10,
justifyContent:'center',
alignItems:"flex-start",
backgroundColor:"#e3eeee"
},
labelSelect:{
marginTop:5,
marginBottom:20,
padding:5,
borderWidth:1,
borderRadius:6,
borderStyle:'dashed',
borderColor:'#6dc2a2'
},
text:{
fontSize:16,
color:'rgb(13, 131, 144)'
}
});
export default MyItskills;
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant