i使用sqlite开发一个反应本机应用程序。
var sqlite = require('react-native-android-sqlite')
var databaseName = 'react.db'
//initialiser base de donnée
sqlite.init(databaseName)
.then((_) => {
console.log('database initialized.')
}
)
//declarer une requette
var sql = 'INSERT INTO principale(id, nom) VALUES (1, bonjour)'
var params = ["Create react native android sqlite", 1]
//fermer la base de donnée
export default class sql2 extends Component {
//function
insert() {
sqlite.query(sql, params)
.then((data) => {
console.log('retrieved: ', data)
}
)
}
render() {
return (
<View style={styles.container}>
<Button title='salut' onPress={this.insert}>Cliquz sur moi</Button>
</View>
);
}
}
AppRegistry.registerComponent('sql2', () => sql2);
我有一个错误:来自本机模块的非法回调类型调用。此回调类型仅允许来自本机代码的单个调用
反应本式android-sqlite已过时。使用sqlite-storage:https://github.com/andpor/reaect-native-sqlite-storage,但使用黄油:https://realm.io/docs/javascript/javascript/latest/#getting startest/#getting-startting-startest-started-pro-start-started/p