with-sqlite example
- Dominant language
- TypeScript
- Stars
- 3.7k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
On opening app on my phone I get the following warning:
Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?%s%s,
Check the render method of `App`.,
in Items (at App.js:108)
in RCTView (at ScrollView.js:1038)
in RCTScrollView (at ScrollView.js:1178)
in ScrollView (at App.js:107)
in RCTView (at App.js:93)
in App (at withExpoRoot.js:26)
in RootErrorBoundary (at withExpoRoot.js:25)
in ExpoRoot (at renderApplication.js:40)
in RCTView (at AppContainer.js:101)
in RCTView (at AppContainer.js:119)
in AppContainer (at renderApplication.js:39)
**To Reproduce**
1. clone repo
2. npm install dependencies for with-sqlite example (could this have been a problem? it said to use yarn)
3. expo start in the command line.
4. select "Tunnel" in expo gui (opens when you do expo start)
5. The warning shows up.
6. Also entering something into the 'what do you need to do?' box does nothing
**Expected behavior**
There should be no warning and after a item is entered into the text input a todo list item should appear
Complete the following information):**
- Device: Moto g(7) Play
- OS: Android 9
- Browser: Chrome
**Additional context**
I don't understand what was going on with the refs. They were initialized with a functional component rather than an element and the method ref.update() was called on Line 82-3, I don't know if that method exists.
lines 80-84:
```
const update = () => {
_todo && _todo.update();
_done && _done.update();
};
```
If the bug is on my end I'd appreciate some help.
I was trying to use this example to help me integrate sqlite into my project, and understand the best practices for how the state of a component should be updated at the same time as the database. It looks like the idea presented here is to make the db query, and update the state with a 'select * from table' query and callback. I also have a question about this.
Looking at this code on line 70:
```
tx => {
tx.executeSql("insert into items (done, value) values (0, ?)", [text]);
tx.executeSql("select * from items", [], (_, { rows }) =>
console.log(JSON.stringify(rows))
);
},
null,
update
);
```
Do we have a guarantee that these queries will be executed in order? Do we have a gaurantee that the callbacks will be called in order? My initial thought was to execute the second query in the callback from the first, but this suggests that's not necessary.
Contributor guide
Assessment
This issue has not been assessed yet.