小编BaH*_*Jr.的帖子

无法将undefined或null转换为对象redux

我正在使用Redux制作一个简单的商店,不幸的是它抛出了这个错误:

 Cannot convert undefined or null to object
Run Code Online (Sandbox Code Playgroud)

浏览器指向导入Redux的行

import * as redux from "redux"
Run Code Online (Sandbox Code Playgroud)

我也尝试过这种方式导入它但它从"redux"给出了相同的错误import {createStore}

这个代码:

import * as redux from "redux"

let reducer = (state ={}, action) =>{
    switch(action.type) {
        case "ADD_POLL":
            return {
                polls: [
                    ...state.polls,
                    action.poll
                ]
            }
        default:
            return state
    }
}

let store = redux.createStore(reducer)

store.subscribe(()=>{
    let currentState = store.getState()
    console.log(currentState)
})

store.dispatch({
    type: "ADD_POLL",
    poll: {
        id: 1,
        title: "What's  your fav Color",
        votes: 230
    }
})
Run Code Online (Sandbox Code Playgroud)

javascript reactjs redux react-redux

7
推荐指数
1
解决办法
1万
查看次数

世博文件不可读

我正在尝试使用 expo FileSystem api 读取此记录文件的内容。

这是代码:

Expo.FileSystem.readAsStringAsync((Platform.OS==='android'?'file://':'')+sound.status.uri).then(str => {
  console.log(str)
})
Run Code Online (Sandbox Code Playgroud)

我收到此错误,当我尝试使用任何 FileSystem 方法移动它时,它会引发相同的错误。

在此处输入图片说明

react-native expo

6
推荐指数
1
解决办法
671
查看次数

标签 统计

expo ×1

javascript ×1

react-native ×1

react-redux ×1

reactjs ×1

redux ×1