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-appearance
Advanced tools
Polyfill for `Appearance` API which will likely be available in `react-native@>=0.61`. iOS only.
Polyfill for Appearance
API to detect preferred color scheme (light/dark) in React Native 0.59, 0.60 and perhaps more (ymmv outside of these two!). The Appearance
API will likely be available in react-native@>=0.61
.
This library is currently iOS only, and on iOS < 13 the color scheme will always be 'no-preference'
.
Install the library using either Yarn:
yarn add react-native-appearance
or npm:
npm install --save react-native-appearance
You then need to link the native parts of the library for the platforms you are using. The easiest way to link the library is using the CLI tool by running this command from the root of your project:
react-native link react-native-appearance
If you can't or don't want to use the CLI tool, you can also manually link the library using the instructions below (click on the arrow to show them):
Either follow the instructions in the React Native documentation to manually link the framework or link using Cocoapods by adding this to your Podfile
:
pod 'react-native-appearance', :path => '../node_modules/react-native-appearance'
First, you need to wrap your app in the AppearanceProvider
. At the root of your app, do the following:
import { AppearanceProvider} from 'react-native-appearance';
export default () => (
<AppearanceProvider>
<App />
</AppearanceProvider>
);
Now you can use Appearance
and useColorScheme
anywhere in your app.
import { Appearance, useColorScheme } from 'react-native-appearance';
/**
* Get the current color scheme
*/
Appearance.get('colorScheme');
/**
* Subscribe to color scheme changes with a hook
*/
function MyComponent() {
let colorScheme = useColorScheme();
if (colorScheme === 'dark') {
// render some dark thing
} else {
// render some light thing
}
}
/**
* Subscribe to color scheme without a hook
*/
let subscription = Appearance.addChangeListener(({ colorScheme }) => {
// do something with color scheme
});
// Remove the subscription at some point
subscription.remove()
This was mostly written by Facebook for inclusion in React Native core. It is provided here as a separate module so people can opt-in to using it without updating entirely to the newest React Native version.
FAQs
Polyfill for `Appearance` API which will be available in `react-native@0.62`.
The npm package react-native-appearance receives a total of 8,450 weekly downloads. As such, react-native-appearance popularity was classified as popular.
We found that react-native-appearance demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.