0
        for(var index in preguntas.questions) {
            var attr1 = preguntas.questions[index]
            console.log(sum + " ***********************************************pregunta" + attr1.text )
            for(var index2 in attr1.answers) {
            var attr4 = attr1.answers[index2];
            respuesta.push(
                <View key = {index2} >
                    <RadioButton   onPress={() =>  this.onSubmitPressed(index2)} >
                        <Text>{attr4}</Text>
                    </RadioButton>

                </View >
            )
            }
            questions.push(
                <View key = {index}>
                    <View>
                        <Text >{attr1.text}</Text>

                        {respuesta}
                    </View>
                </View>
            )
            var respuesta = [];
            /*for(var index55 in attr2.answers) {
                var attr4 = attr2.answers[index2];
                console.log(sum + " ***********************************************" + attr4 )
                respuesta.push(`enter code here`
                <View key = {index55}>
                    <View>
                        <Text >{attr4}</Text>
                    </View>
                </View>
                )
            }*/



        }

Good morning I'm trying to run the onpres function that is onSubmitPressed but it will not let me and I get the following error ReactNativeJS: NETWORK error: TypeError: undefined is not a function (evaluating 'this.onSubmitPressed (index2)')

The code is inside the renderMovie function If I could help with that greetings

1
  • 1
    Can you show the whole code? Where did you place that function? Is it in the same file as the code above? And is this a reactjs (web) or react-native (mobile apps) question? Commented May 16, 2017 at 16:25

1 Answer 1

1

So it looks like the onSubmitPressed is not defined, what you will need to do is declare that function in your component and then also bind(this) if you want to use the state and any other values inside your this.

onSubmitPressed(index2) {
  //Do whatever you would like on your submit
}

constructor(props) {
  super(props)
  this.state = {};
  this.onSubmitPressed = this.onSubmitPressed.bind(this);
}
Sign up to request clarification or add additional context in comments.

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.