Answer the question
In order to leave comments, you need to log in
How would you do this in React Redux (rendering data received from the API)?
You need to render the data on the page received from this request
https://api.coinmarketcap.com/v1/ticker/bitcoin/?c...
Answer the question
In order to leave comments, you need to log in
Something like this?
(I assembled it on my knee, you don’t think that they will write the program for you)
import {appName} from '../config'
import {Record} from 'immutable'
import {createSelector} from 'reselect'
/**
* Constants
* */
export const moduleName = 'bitcoin'
const prefix = `${appName}/${moduleName}`
export const INIT = `${prefix}/INIT`
/**
* Reducer
* */
const ReducerRecord = Record({
bitcoin: null
})
export default function reducer(state = new ReducerRecord(), action) {
const {type, payload} = action
switch (type) {
case INIT:
return state.set('bitcoin', payload)
default:
return state
}
}
/**
* Selectors
* */
export const bitcoinSelector = state => state[moduleName].bitcoin
/**
* Action Creators
* */
export function bitcointInit(url) {
return (dispatch) => {
fetch(url)
.then((data) => {
dispatch({
type: INIT,
payload: data
})
});
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question