react-native-component-kits

React Native Components


Keywords
react-native, minhchienwikipedia, react-native-component-kits, ios, android
License
MIT
Install
npm install react-native-component-kits@1.0.3

Documentation

react-native-component-kits

npm version npm

NPM

Getting started

$ npm install react-native-component-kits --save

  • OR

$ yarn add react-native-component-kits

Descriptions

This library will help you improve your code, faster and easier.

Functions

Functions Description Type
memoDeepEqual Using memo of React but deep compare preProps with nextProps to check component should be return true or false. Higher Order Function
memoWithRef It's like memoDeepEqual but using forwardRef to get ref of component. Higher Order Function
useStateCallback Using useState of React and handle to get callback after setState Hook
dectectEmail Check string is email Boolean
dectectUserName Check string is user name Boolean
dectectPhoneNumber Check string is user phone number Boolean

How to use

memoDeepEqual

const App = ()=>{
    return <Text>Hello</Text>
}
export default memoDeepEqual(App) 

// OR

const App = memoDeepEqual(()=>{
    return <Text>Hello</Text>
})

export default App

memoWithRef

const App = (props, ref)=>{
    const updateValue = (value)=>{
        console.log(value)
    }

    useImperativeHandle(
        ref,
        () => ({
            updateValue  
        }),
        [],
    )
    return <Text>Hello</Text>
}
export default memoWithRef(App) 

useStateCallback

const [state, setState] = useState(initialState)

setState('123',(nextState)=>{
    console.log(nextState)
})

License

This module is MIT licensed