Skip to content

Instantly share code, notes, and snippets.

View luyx2412's full-sized avatar
🎯
Focusing

luyx2412 luyx2412

🎯
Focusing
View GitHub Profile
@luyx2412
luyx2412 / WaitForUI.js
Created June 14, 2019 03:47 — forked from iremlopsum/WaitForUI.js
InteractionManager example
import React, { PureComponent } from 'react';
import { InteractionManager } from 'react-native';
class WaitForUI extends PureComponent {
constructor(props) {
super(props);
this.state = {
interactionsComplete: false,
};
}
@luyx2412
luyx2412 / ReactNativeExtensions.kt
Created June 4, 2019 13:57 — forked from ericksli/ReactNativeExtensions.kt
React Native Kotlin extension functions for creating WritableMap and WritableArray #android #react-native #kotlin
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.WritableArray
import com.facebook.react.bridge.WritableMap
fun writableMapOf(vararg values: Pair<String, *>): WritableMap {
val map = Arguments.createMap()
for ((key, value) in values) {
when (value) {
null -> map.putNull(key)
is Boolean -> map.putBoolean(key, value)

Rule coding

- `templates` folder contains all templates UI. And have `assets` folder have data, images,... file.
- Each component if have two files or more --> create a folder components. And if have one file which have the name without folder 
Examples: `Settings` folder --> has `index.js` and `SettingList.js` file. `index.js` is main file. If have one file which will only is `Settings.js` file.
- Each `styles` must locate inside file component.
Examples: https://www.screencast.com/t/Oein7wwZK
- Should be format code before commit code. Install prettier-vscode https://github.com/prettier/prettier-vscode. The `prettierrc` file existed in the project.
- Eslint installed in the project. If have any waring, please remove or fix it.
@luyx2412
luyx2412 / ModelWithDownload.js
Created November 9, 2018 15:50 — forked from bnjm/ModelWithDownload.js
Example how to download a 3dmodel from the internet using react-native-arkit
// @flow
import { ARKit } from 'react-native-arkit'
import { branch, compose, lifecycle, renderComponent } from 'recompose'
import { unzip } from 'react-native-zip-archive'
import RNFetchBlob from 'react-native-fetch-blob'
import React from 'react'
const getModelPath = modelId => (
`${RNFetchBlob.fs.dirs.CacheDir}/models/${modelId}/`
)
@luyx2412
luyx2412 / ...txt
Last active June 29, 2018 10:54
improve performance note React Native
- Should be use PureComponent to avoid re-render many times --> https://reactjs.org/docs/react-api.html#reactpurecomponent
- Seperate Container file and Component file --> https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0
- Avoid use .bind when handle function --> https://stackoverflow.com/a/32192892/6622971
- Don’t use arrow functions in your render methods --> onPress={(e) => this.handlePress(e)} --> only use when need pass params to handle, or
export default ({deleteItem, item}) => {
const _onDeleteTap(){
deleteItem(item.id)
}
return(
<TouchableOpacity onPress={_onDeleteTap}>
@luyx2412
luyx2412 / HighPureComponent
Created March 22, 2018 13:48
High PureComponent React Native (compare include function)
// Author: @tomzaku from https://gist.github.com/tomzaku/ccda8d03b8a35c92025a84cd14d0369b
// import liraries
import React, { Component } from 'react';
import _ from 'lodash'
// create a component
export const isEqualObjectIncludeFunction = (first, second) => {
return _.isEqualWith(first, second, (val1, val2) => {
// Compare include function
@luyx2412
luyx2412 / google-drive.js
Last active July 14, 2021 13:03
React native login google, and google drive. Save storage and get again data when uninstall app.
/**
* Google Drive
* created by luyxtran264@gmail.com
*/
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
@luyx2412
luyx2412 / 0_reuse_code.js
Created July 1, 2017 16:52
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console