I have a very simple ViewController written in Swift with its user interface built into the Storyboard. It just changes the text of the label when someone presses a button.
class ViewController: UIViewController {
@IBOutlet weak var label: UILabel!
@IBAction func changeText() {
switch label.text! {
case "Old Text":
label.text = "New Text"
case "New Text":
label.text = "Old Text"
default:
break
}
}
}
I want to use React Native for my project, but only for handling user interface components, not the application logic itself. How can i do this? I laid out the button and the text with the answer.
var Button = require('react-native-button');
class TestProject extends Component {
render() {
return (
<View style={styles.container}>
<Button style={styles.button}>Change Text</Button>
<Text style={styles.text}>
Text to be changed
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
text: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
button: {
borderWidth: 1,
borderColor: 'blue'
},
});
In a broader sense, if what I want is it possible, is it possible to use this approach for more powerful and reliable applications?
source
share