Usage with Reactjs
Hello i would like to ask you If I'm able to use this lib with react. I downloaded sql.jq file and I'm trying to import it like import {SQL} from "./sql";
but when i start development server i get into some infinite loop. I'm also not able to found some debug logs for what is happening here. The console is stucked on Compiling... message
I also tried to import it using require keyword like const SQL = require('./sql') but it didn't work either.
Many thanks for any help!
I was able to get SQL object by injecting index.html file in public folder:
...
<title>React App</title>
</head>
<body>
<script src='js/sql.js'></script>
<div id="root"></div>
...
So now I'm able to get SQL object by window.SQL. Anyway I really would like to be able to import it from my .js files, where database should be opened... Any suggestions?
Did you tried to get it from npm using the code from readme?
Similar problem, I have installed sql.js through yarn and started setting up a basic api. The problem is importing the api functions to use in react, where it says compiling.. until i get: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory Any idea how to incorporate sql.js with react? Or the suggested approach?
@simonsankar: Your problem is caused by node running out of memory. You can avoid that by passing --max_old_space_size to node. I do that by setting an environment variable:
export NODE_OPTIONS=--max_old_space_size=4096
@kaizhu256 Thanks! Very much appreciated. I was going down the rabbit hole with sqlite3 and had a similar issue importing that module. This seemed to solve it
Hi all! I wrote a small library to wrap the sql.js in a React[ish] API. It is in the early development, and I wish to humbly ask for a feedback on it. I name it reactive-sql-toolkit, it is already in npm for testing (https://www.npmjs.com/package/reactive-sql-toolkit)
Any feedback would be very much appreciated. Thank you all!