Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
react-native-comp-util
Advanced tools
Utility components for better react native development experience
Utility components for better react native development experience.
__DEV__
environment onlyref
helper methodTouchableNativeFeedback
for iOS and Webnpm install react-native-comp-util
import { Component } from 'react'
import { View, Text } from 'react-native'
import { Comp, Compact, TouchableNativeFeedback } from 'react-native-comp-util'
class FirstComp extends Compact {
someMethod() {
// console.log() but with some helpful formatting for development CLI
this.log('FirstComp.someMethod() was called')
}
render() {
// super.render() call will prevent this component from updating later on
super.render()
return (
<Text>Hello First Comp</Text>
)
}
}
class SecondComp extends Comp {
onPress = () => {
this.$firstComp.someMethod()
// or use this way
// this.$('firstComp').someMethod()
}
render() {
return (
// TouchableWithoutFeedback will be used on iOS and Web
<TouchableNativeFeedback
onPress={this.onPress}
background={TouchableNativeFeedback.Ripple(`rgba(0,0,0,0.32)`, false)}
>
<View>
<Text>Hello Second Comp</Text>
<FirstComp ref={this.$$('firstComp')} />
</View>
</TouchableNativeFeedback>
)
}
}
export default SecondComp
This class extends React's Component
class with some useful methods.
log(...messages:any)
It is a formatted development logging method which is only prints logs in development builds (when __DEV__
is true) and it is just an empty function otherwise. format includes the name of the component class, equal gap before messages and a collapsed stack trace on the web devTools.
rerender()
It is a method that calls forceUpdate()
on the component
$$(refName:String):function
It creates a reference of a component instance when used like <View ref={this.$$('compName')}></View>
on the component
$(refName:String):ComponentInstance
It returns a reference of a component instance created by $$('compName')
which can be used like this.$compname.someMethod()
or like this.$('compname').someMethod()
_:Object
It contains the references created by $$('compName')
This class extends Comp
class with 2 additional methods.
render()
It sets property rendered = 1
and increments property renderCount
by 1 and this method is to be used like super.render()
in the implemented render method.
shouldComponentUpdate():Boolean
It checkes rendered
property and returns false if it is not equal to zero, which will prevent the component from updating.
On iOS and Web, it extends React Native's TouchableWithoutFeedback
with static methods like Ripple()
, SelectableBackground()
, SelectableBackgroundBorderless()
, canUseNativeForeground()
for compatibility with TouchableNativeFeedback usage.
The MIT License (MIT)
Copyright (c) 2020 Md. Naeemur Rahman (https://naeemur.github.io)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Utility components for better react native development experience
We found that react-native-comp-util 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.