Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

295
Views
SQLite not working with Redux in React-native

After introducing redux to my react-native expo app, for some reason whenever I try to interact with the database it makes my app stop working. I have no idea what could be causing this and I could not find anything about it online.

Redux files are as follows:

actions.js:

  export const SET_SELECTED_PLAYERS = "SET_SELECTED_PLAYERS"
export const SET_PLAYERS = "SET_PLAYERS"
export const SET_SELECTED_COURSE = "SET_SELECTED_COURSE"
export const SET_COURSES = "SET_COURSES"


//Player actions

export const setPlayers = (players) => (
    { type: SET_PLAYERS, payload: players, }
)

export const setSelectedPlayers = (players) => (
    ({ type: SET_SELECTED_PLAYERS, payload: players, })
)

export const setSelectedCourse = (course) =>
    ({ type: SET_SELECTED_COURSE, payload: course, })


export const setCourses = (courses) =>
    ({ type: SET_COURSES, payload: courses, })

reducers.js:

    import { SET_PLAYERS, SET_SELECTED_PLAYERS, SET_SELECTED_COURSE, SET_COURSES } from "./actions"

const initialState = {
    players: [],
    selectedPlayers: [],
    courses: [],
    selectedCourse: null,
    round: {}
}

export const playerReducer = (state = initialState, action) => {
    switch (action.type) {
        case SET_PLAYERS:
            return { ...state, players: action.payload }
        case SET_SELECTED_PLAYERS:
            return { ...state, selectedPlayers: action.payload }
        default:
            return state
    }
}

export const courseReducer = (state = initialState, action) => {
    switch (action.type) {
        case SET_SELECTED_COURSE:
            return { ...state, selectedCourse: action.payload }
        case SET_COURSES:
            return { ...state, courses: action.payload }
        default:
            return state
    }
}

store.js:

    import { createStore, combineReducers, applyMiddleware } from "redux";
import { courseReducer, playerReducer } from "./reducers";



const rootReducer = combineReducers({ playerReducer, courseReducer })



export const Store = createStore(rootReducer)

And sqlite database being used in one component like so:

const dispatch = useDispatch()
const db = SQLite.openDatabase("players.db")
useEffect(() => {
    db.transaction(tx => {
        tx.executeSql("SELECT * FROM Player", [], (trans, result) => {
            dispatch(setPlayers(result.rows._array))
        })
    })
}, [])

Table for Player has been created, app worked nicely before I introduced Redux. My app interacts with Firebase and when fetching data from cloud Redux has no problems with it. No idea what problems it could have with SQLite. Thanks in advance for any help.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!