Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
react-native-button
Advanced tools
A button for React apps
Install the button from npm with npm install react-native-button --save
. Then, require it from your app's JavaScript files with import Button from 'react-native-button'
.
import React, { Component } from 'react';
import Button from 'react-native-button';
export default class ExampleComponent extends Component {
constructor(props, context) {
super(props, context);
}
_handlePress() {
console.log('Pressed!');
}
render() {
return (
<Button
style={{fontSize: 20, color: 'green'}}
styleDisabled={{color: 'red'}}
onPress={() => this._handlePress()}>
Press Me!
</Button>
);
}
};
The React packager will include the Button component in your app's JS package and make it available for your app to use.
You can control a button's state by setting disabled
prop value in this way:
import React, { Component } from 'react';
import Button from 'react-native-button';
export default class ExampleComponent extends Component {
constructor(props, context) {
super(props, context);
this.state = {
isDisabled: false
}
}
_handlePress() {
this.setState({
isDisabled: true
});
console.log('Now, button disabled');
}
render() {
const { isDisabled } = this.state;
return (
<Button
style={{ fontSize: 20, color: 'white' }}
styleDisabled={{ color: 'white' }}
disabled={isDisabled}
containerStyle={{ padding: 10, height: 45, overflow: 'hidden', borderRadius: 4, backgroundColor: 'aqua' }}
disabledContainerStyle={{ backgroundColor: 'pink' }}
onPress={() => this._handlePress()}
>
Press Me!
</Button>
);
}
};
Prop | Required | Type | Description |
---|---|---|---|
accessibilityLabel | No | String | VoiceOver will read this string when a user selects the associated element. |
allowFontScaling | No | Bool | Specifies whether fonts should scale to respect Text Size accessibility settings. |
Disabled | No | Bool | Disables the button |
Style | No | View Style Prop | The style for the button |
styleDisabled | No | View Style Prop | The style for the disabled button |
containerStyle | No | View Style Prop | The style for the container |
disabledContainerStyle | No | View Style Prop | The style for the container when the button is disabled |
childGroupStyle | No | View Style Prop | The style for the child views |
androidBackground | No | Background Prop Type | The background for andriod devices. |
onPress | No | Function | Handler to be called when the user taps the button. |
You can make a button with rounded corners like this:
<Button
containerStyle={{padding:10, height:45, overflow:'hidden', borderRadius:4, backgroundColor: 'white'}}
disabledContainerStyle={{backgroundColor: 'grey'}}
style={{fontSize: 20, color: 'green'}}>
Press me!
</Button>
Contributions are welcome. Please verify that styling matches the latest version of iOS when you are changing the visual look of the buttons.
FAQs
A button for React apps
The npm package react-native-button receives a total of 19,569 weekly downloads. As such, react-native-button popularity was classified as popular.
We found that react-native-button demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.