小编Hap*_*ala的帖子

Getting number of records from JSON server end point

I'm creating a mock application with JSON server as the backend and I'm wondering if it is possible to get the total number of records contained at an end point without loading all the records themselves? Assuming the db.json file looks like the JSON snippet below, how would I find out that the end point only has one record without fetching the record itself, provided it's possible?

    {
      "books": [{
      "title": "The Da Vinci Code",
      "rating": "0"}]
    }
Run Code Online (Sandbox Code Playgroud)

javascript json

4
推荐指数
3
解决办法
5406
查看次数

Redux未连接到React组件

我一直在玩Redux,但我似乎无法与React联系.我使用connectmapStateToProps,但在我的商店道具不被传递到我的组件.也许有人可以解释为什么我的代码不起作用?我猜它与mapStateToProps函数有关.

这是我得到的代码:

import { connect, Provider } from 'react-redux';
import { createStore, combineReducers } from 'redux';
import React from 'react';
import ReactDOM from 'react-dom';`enter code here`


const greetReducer = ( state = '', action ) => {

  if ( action.type === 'greet' ) {

  state = action.greeting

  }

  return state;

};

const runReducer = ( state = '', action ) => {

  if ( action.type === 'run' ) {

    state = action.running

  }

  return state;

}; …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs redux

3
推荐指数
1
解决办法
350
查看次数

标签 统计

javascript ×2

json ×1

reactjs ×1

redux ×1