Skip to content

Instantly share code, notes, and snippets.

View arnoldc's full-sized avatar
🏠
Working from home

Arnold Camas arnoldc

🏠
Working from home
  • Philippines
  • 20:03 (UTC -12:00)
View GitHub Profile
@arnoldc
arnoldc / foo.js
Created October 29, 2021 11:05
[React Native] Create circle radius
outerCircle: {
backgroundColor: 'blue',
width: 100,
height: 100,
borderRadius: 100/2,
justifyContent: 'center',
alignItems: 'center'
},
@arnoldc
arnoldc / foo.js
Last active October 29, 2021 11:12
[React] useEffect
// Noted the empty array. useEffect will then only run once on initial render
useEffect(() => {
document.title = `New value: ${value}`
}, [])
// Will run each time 'value' state change.
useEffect(() => {
document.title = `New value: ${value}`
@arnoldc
arnoldc / foo.js
Last active September 7, 2023 17:09
[React] useRef
const UseRefBasics = () => {
const refContainer = useRef(null)
const handleSubmit = (e) => {
e.preventDefault()
console.log(refContainer.current.value)
}
@arnoldc
arnoldc / foo.txt
Last active January 29, 2023 09:04
[React Native] React Navigation
// our wrappper
import { NavigationContainer } from '@react-navigation/native';
const App = () => (
<NavigationContainer>
{ /* Insert your navigators and content here */ }
</NavigationContainer>
@arnoldc
arnoldc / foo.js
Last active October 29, 2021 11:15
[React Native] Styling
// ways
<Text style={styles.paragraph} />
<Text style={{ fontSize: 16 }} />
<Text style={[styles.paragraph, { color: 'red' }]} />
// dynamic
// Applies the `selected` style on top of the `paragraph` style if props.isActive is truthy
function Item(props) {
@arnoldc
arnoldc / foo.js
Created October 29, 2021 11:15
[React Native] Image component
<Image source={require('./local/asset.jpg')} />
<Image source={{ uri: 'https://docs.expo.io/static/images/header/sdk.svg' }} />
<Image source={{ uri: 'data:image/png;base64,<base64-string>=' }} />
@arnoldc
arnoldc / foo.js
Created October 29, 2021 11:16
[React Native] Textinput
const [input, setInput] = useState('');
// example use of input
console.log(input);
return (
<TextInput
placeholder="What is your name?"
onChangeText={setInput}
/>
@arnoldc
arnoldc / foo.jsx
Last active November 2, 2021 06:36
[React Native] Pull to Refresh Example
import React, { useState, useEffect } from 'react';
import {
SafeAreaView,
StyleSheet,
ActivityIndicator,
FlatList,
Text,
View,
RefreshControl,
} from 'react-native';
@arnoldc
arnoldc / foo.tsx
Last active November 3, 2021 07:26
[React Native] RN Navigation
// bottom navigator
// https://reactnavigation.org/docs/bottom-tab-navigator
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
const Tab = createBottomTabNavigator();
@arnoldc
arnoldc / foo.ts
Last active November 3, 2021 10:45
[Typescript] Access modifiers
// make sure access modifier are stated (e.g public , private)
// adding readonly for not needed to be modified
export class User {
public readonly id: number;
public firstName: string;
public lastName: string;
public email: string;
protected dob: Date;