You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm new to React Native, and working on an experimental app where I'm using MKButton. I have asked the same question at StackOverflow but didn't had any proper solution, so I thought to ask you here.
Based on my limited knowledge, I've constructed the MKButton in following way:
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
ScrollView
} from 'react-native';
import Icon from 'react-native-vector-icons/EvilIcons';
import {MKTextField, MKColor, MKButton} from 'react-native-material-kit';
import {connect} from 'react-redux';
import * as actions from '../actions';
const getButtonLabel = () =>
{
if (!this.props.toUpdate)
{
return 'ADD';
}
else
{
return 'UPDATE';
}
}
const AddButton = MKButton.coloredButton()
.withText({getButtonLabel()}).build();
type Props = {};
class AddPerson extends Component<Props>
{
render() {
return (
return (
<View style={styles.addButton}>
<AddButton onPress={this.onButtonPress.bind(this)}/>
</View>
);
}
}
const mapStateToProps = state => {
return {
toUpdate: state.toUpdate,
};
};
export default connect(mapStateToProps, actions)(AddPerson);
But I couldn't able to get it work due to different undefined reference errors at different times, or just no rendering of the button at all.
I see there's a way documented at here, but this also so much of writing and not renders same as button created with MKButton.coloredButton().build(), unfortunately:
I don't think there is a way, because the builder version creates a Text internally and doesn't expose any reference outside. If you want it to be the same as builder version, try reading the source code to see what it is styled inside:
Hi,
I'm new to React Native, and working on an experimental app where I'm using
MKButton
. I have asked the same question at StackOverflow but didn't had any proper solution, so I thought to ask you here.Based on my limited knowledge, I've constructed the
MKButton
in following way:But I couldn't able to get it work due to different undefined reference errors at different times, or just no rendering of the button at all.
I see there's a way documented at here, but this also so much of writing and not renders same as button created with
MKButton.coloredButton().build()
, unfortunately:Can we do this in a
.build()
way and also change the label based on state change?Thanks!
The text was updated successfully, but these errors were encountered: