Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. import {createStore, applyMiddleware} from 'redux';
  2. import Reducers from './Reducer'
  3. import thunk from 'redux-thunk'
  4.  
  5. export default SettingStore = () => {
  6. let store = createStore(Reducers, applyMiddleware(thunk))
  7. return store
  8. }
  9.  
  10. import {combineReducers} from 'redux';
  11. import loginreducer from './login.reducer'
  12.  
  13. export default combineReducers({
  14. login: loginreducer,
  15.  
  16. })
  17.  
  18. import {FETCHING_GETDATA_PARVU} from '../Constante'
  19. import {GetParv} from '../Api/Parvularia.api'
  20.  
  21.  
  22.  
  23. export const getParvuSuccess = (data) => {
  24. return {type: FETCHING_GETDATA_PARVU, data}
  25. }
  26.  
  27. export const GetParvu = () => {
  28. return (dispatch) => {
  29.  
  30. dispatch(getData())
  31.  
  32. GetParv(1)
  33. .then(([response, json]) => {
  34. dispatch(getParvuSuccess(json))
  35. })
  36. .catch((error) => console.log(error))
  37. }
  38. }
  39.  
  40. import {FETCHING_GETDATA_PARVU} from '../Constante'
  41.  
  42. const initialState = {
  43. data: [],
  44. isFeching: false,
  45. error: false
  46. }
  47.  
  48. export default dataReducer = (state = initialState, action) => {
  49. switch(action.type) {
  50. case FETCHING_GETDATA_PARVU:
  51. return {
  52.  
  53. ...state,
  54. data: action.data,
  55. isFeching: false
  56. }
  57. default:
  58. return state
  59. }
  60. }
  61.  
  62. import React, { Component } from 'react';
  63. import { Platform, StyleSheet, Text, View } from 'react-native';
  64. import {Provider} from 'react-redux';
  65. import Lista from '../screens/Educadora/Lista';
  66. import SettingStore from './SettingStore'
  67.  
  68. let store = SettingStore()
  69.  
  70.  
  71. const Ap = () => (
  72. <Provider store={store}>
  73. <Lista/>
  74. </Provider>
  75. )
  76.  
  77. export default Ap;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement