Skip to content

Instantly share code, notes, and snippets.

Claudio Orlandi csorlandi

Block or report user

Report or block csorlandi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View global.js
import { createGlobalStyle, css } from 'styled-components';
import 'font-awesome/css/font-awesome.css';
import './UI-v1/main.scss';
import Auth from '../services/auth';
const GlobalStyle = createGlobalStyle`
${Auth().guest
&& css`
body {
View offline-queue.js
// Estrutura da Action para entrar na Fila de Ações Offline
type ActionToBeQueued = {
type: string,
payload?: any,
meta: {
retry?: boolean, // By passing true, your action will be enqueued on offline mode
dismiss?: Array<string> // Array of actions which, once dispatched, will trigger a dismissal from the queue
}
}
View redux-with-persist.js
// Redux + Redux Persist
const App = () => (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<Routes />
</PersistGate>
</Provider>
);
View async-storage-query.js
// Recuperação de Registros com o Async Storage
try {
const value = await AsyncStorage.getItem('TASKS');
if (value !== null) {
// We have data!!
console.log(value);
}
} catch (error) {
// Error retrieving data
View realmdb-query.js
// Exemplo de uso do RealmDB
let realm = new Realm({ schema: [Person] });
realm.addListener((sender, name) => {
if (name === 'change') {
this.setState({ source: sender.objects('Dog') });
}
});
View action.js
{
type: 'ADD_REQUEST',
payload: {
id: 1
data: { username: 'csorlandi', email: 'claudio@rocketseat.com.br', password: '123456' },
},
meta: {
retry: true
}
}
View FlatListExample.js
import React, { Component } from 'react';
export default class Main extends Component {
state = {
docs: [],
page: 1,
productInfo: {},
}
componentDidMount() {
View callback-toggle-button.js
onPress={() => {
if (this.state.language === "en") {
I18n.locale = "pt";
} else {
I18n.locale = "en";
}
this.setState({ language: getCurrentLocale() });
}}
View App-render.js
render() {
return (
<View style={styles.container}>
<View style={styles.insideContainer}>
<StatusBar
barStyle="light-content"
backgroundColor={styles.container.backgroundColor}
/>
<Text style={styles.title}>{I18n.t("HOME_pageTitle")}</Text>
<Text style={styles.language}>
View i18n.js
import RNLanguages from "react-native-languages";
import i18n from "i18n-js";
import en from "../config/translations/en.json";
import pt from "../config/translations/pt.json";
i18n.locale = RNLanguages.language;
i18n.fallbacks = true;
i18n.translations = { en, pt };
You can’t perform that action at this time.