See an error in snacks

import * as React from ‘react’;
import { Text, View, TouchableOpacity, StyleSheet } from ‘react-native’;
export default class calculator extends react.component {
state = {
display: ‘’,
};
_handleClick(btnval) {
let result = this.state.display;
result += btnval
this.setState({
dispaly: result,
});
}
render() {
return (

{this.state.display}

  <View style={styles.row}>
    <MyButton Val={7} handleClick={this._handleClick.bind(this)}/>
    <MyButton Val={8} handleClick={this._handleClick.bind(this)}/>
    <MyButton Val={9} handleClick={this._handleClick.bind(this)}/>
    <MyButton Val={'/'} handleClick={this._handleClick.bind(this)/>
   </View>


 <View style={styles.row} 

   <MyButton Val={4} handleClick={this._handleClick.bind(this)}/>
   <MyButton Val={5} handleClick={this._handleClick.bind(this)}/>
   <MyButton Val={6} handleClick={this._handleClick.bind(this)}/>
   <MyButton Val={'*'} handleClick={this._handleClick.bind(this)}/>
   </View>


 <View style={styles.row}>
   <MyButton Val={1} handleClick={this._handleClick.bind(this)}/>
   <MyButton Val={2} handleClick={this._handleClick.bind(this)}/>
   <MyButton Val={3} handleClick={this._handleClick.bind(this)}/>
   <MyButton Val={'-'} handleClick={this._handleClick.bind(this)}/>
   </View>  


 <View style={styles.row}>
    <MyButton Val={'Del'} handleClick={this._handleClick.bind(this)}/>
    <MyButton Val={0} handleClick={this._handleClick.bind.(this)}/>
    <MyButton Val={'='} handleclick{this._handleClick.bind(this)} />
    <MyButton Val={'+'} handleClick={this._handleClick.bind(this)} />
   </View>
 </View>   

);

}
}

Can you make a snack so that I can help you?

I’m make snack but I can’t preview it

import * as React from ‘react’;
import { Text, View, TouchableOpacity, StyleSheet } from ‘react-native’;
export default class calculator extends react.component {
state = {
display: ‘’,
};
_handleClick(btnval) {
let result = this.state.display;
result += btnval
this.setState({
dispaly: result,
});
}
render() {
return (

{this.state.display}

<View style={styles.row}

);

}
}

Hey @doll381,

From a quick glance it looks like you have react.component when you should have React.Component. Also, when posting code in a forum post, look for the </> icon in the toolbar above the text input to create a code snippet which will make the code readable and formatted properly.

Cheers,
Adam

Try to change react.component to React.Component as @adamjnav

Tank you so much guys :heart: I’m very thankful to you now my coding is work

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.