Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Building Something Great

Inifnitbility infinitbility

🎯
Building Something Great
View GitHub Profile
@infinitbility
infinitbility / app.js
Created Mar 29, 2020
React Native SQLite Storage
View app.js
// Add this code on your app.js
import SQLite from 'react-native-sqlite-storage';
global.db = SQLite.openDatabase(
{
name: 'SQLite',
location: 'default',
createFromLocation: '~SQLite.db',
},
@infinitbility
infinitbility / create-table.js
Last active Mar 29, 2020
Create Table on React Native SQLite Storage
View create-table.js
import React from 'react';
import SQLite from 'react-native-sqlite-storage';
export default class SQLiteScreen extends React.Component {
constructor() {
super();
SQLite.DEBUG = true;
}
/**
View insert.js
import React from 'react';
import SQLite from 'react-native-sqlite-storage';
export default class SQLiteScreen extends React.Component {
constructor() {
super();
SQLite.DEBUG = true;
}
/**
View update.js
import React from 'react';
import SQLite from 'react-native-sqlite-storage';
export default class SQLiteScreen extends React.Component {
constructor() {
super();
SQLite.DEBUG = true;
}
/**
View delete.js
import React from 'react';
import SQLite from 'react-native-sqlite-storage';
export default class SQLiteScreen extends React.Component {
constructor() {
super();
SQLite.DEBUG = true;
}
/**
View select.js
import React from 'react';
import SQLite from 'react-native-sqlite-storage';
export default class SQLiteScreen extends React.Component {
constructor() {
super();
SQLite.DEBUG = true;
}
/**
View joins.js
import React from 'react';
import SQLite from 'react-native-sqlite-storage';
export default class SQLiteScreen extends React.Component {
constructor() {
super();
SQLite.DEBUG = true;
}
/**
View ScrollView-Scroll.js
<ScrollView
showsVerticalScrollIndicator={false}
// define ref
ref={ref => (this.ScrollView = ref)}
// use for store scrolled value
onScroll={event =>
this.setState({horizontalScroll:event.nativeEvent.contentOffset.x, VerticalScroll:event.nativeEvent.contentOffset.y})
}
>
// Your list data
View auto-scroll.js
// auto scroll function
autosScroll(){
// X use for horizontal
let horizontalScroll = this.state.horizontalScroll;
// Y use for Vertical
let VerticalScroll = this.state.VerticalScroll;
this.ScrollView.scrollTo({x: horizontalScroll, y: VerticalScroll, animated: true});
View create-refs.js
class MyComponent extends React.Component {
constructor(props) {
super(props);
this.ScrollView = React.createRef();
}
}