Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- import ReactDOM from 'react-dom';
- import { Provider } from 'react-redux'
- import store from './components/store/store'
- import App from './App';
- import * as serviceWorker from './serviceWorker';
- ReactDOM.render(
- <Provider store={store()}>
- <App />
- </Provider>,
- document.getElementById('root')
- );
- serviceWorker.unregister();
- import React, { Component } from 'react'
- import { connect } from 'react-redux'
- import { BrowserRouter as Router, Route } from 'react-router-dom'
- import { addDataAction } from './components/actions/addDataAction'
- etc...
- class App extends Component {
- render() {
- return (
- <Router>
- <div className="App">
- <div className="wrapper">
- <Header />
- <main>
- {console.log(this.props.data.tshirts)} <-- empty object?
- </main>
- </div>
- <Footer />
- </div>
- </Router>
- )
- }
- }
- const mapStateToProps = state => ({
- ...state
- })
- const mapDispatchToProps = dispatch => ({
- addDataAction: () => dispatch(addDataAction)
- })
- export default connect(mapStateToProps, mapDispatchToProps)(App);
- import clothesData from '../json/clothes.data.json'
- export const addDataAction = {
- type: 'ADD_JSON_DATA',
- data: clothesData
- }
- export default (state, action) => {
- switch (action.type) {
- case 'ADD_JSON_DATA':
- return {
- data: action.data
- };
- default:
- return state;
- }
- }
- import { createStore } from "redux"
- import addDataReducer from "../reducers/addDataReducer"
- function store( state = { data: {} } ) {
- return createStore(addDataReducer, state)
- }
- export default store
- "dependencies": {
- "gulp": "^4.0.0",
- "gulp-sass": "^4.0.2",
- "gulp-util": "^3.0.8",
- "react": "^16.8.6",
- "react-dom": "^16.8.6",
- "react-redux": "^7.0.2",
- "react-router-dom": "^5.0.0",
- "react-scripts": "2.1.8",
- "redux": "^4.0.1",
- "redux-devtools": "^3.5.0"
- }
- {
- "tshirts" : [
- {
- "id": 707860,
- "brand": "H&M",
- "name": "T-Shirt",
- "photo": "tshirt.jpg",
- "colors": [
- "red",
- "blue",
- "green",
- "gray"
- ],
- "sizes": [
- "S",
- "M",
- "L",
- "XL"
- ],
- "price": 14,
- "currency": "GBP"
- },
- {
- "id": 43455,
- "brand": "Topman",
- "name": "The Tee Shirt",
- "photo": "tshirt.jpg",
- "colors": [
- "red",
- "blue",
- "green",
- "gray"
- ],
- "sizes": [
- "S",
- "M",
- "L",
- "XL"
- ],
- "price": 14,
- "currency": "GBP"
- }
- ],
- "jumpers" : [
- {
- "id": 653655,
- "brand": "H&M",
- "name": "The J Jumper",
- "photo": "jumper.jpg",
- "colors": [
- "red",
- "blue",
- "green",
- "gray"
- ],
- "sizes": [
- "S",
- "M",
- "L",
- "XL"
- ],
- "price": 24,
- "currency": "GBP"
- },
- {
- "id": 43455,
- "brand": "Topman",
- "name": "Une Jupe",
- "photo": "jumper.jpg",
- "colors": [
- "red",
- "blue",
- "green",
- "gray"
- ],
- "sizes": [
- "S",
- "M",
- "L",
- "XL"
- ],
- "price": 23,
- "currency": "GBP"
- }
- ],
- "trousers" : [
- {
- "id": 645645,
- "brand": "Next",
- "name": "The Trow Sir",
- "photo": "trousers.jpg",
- "colors": [
- "red",
- "blue",
- "green",
- "gray"
- ],
- "sizes": [
- "S",
- "M",
- "L",
- "XL"
- ],
- "price": 24,
- "currency": "GBP"
- },
- {
- "id": 54555,
- "brand": "Topman",
- "name": "Une Trow",
- "photo": "trousers.jpg",
- "colors": [
- "red",
- "blue",
- "green",
- "gray"
- ],
- "sizes": [
- "S",
- "M",
- "L",
- "XL"
- ],
- "price": 23,
- "currency": "GBP"
- }
- ],
- "jackets" : [
- {
- "id": 44344,
- "brand": "Gap",
- "name": "Gap Jacket",
- "photo": "jacket.jpg",
- "colors": [
- "red",
- "blue",
- "green",
- "gray"
- ],
- "sizes": [
- "S",
- "M",
- "L",
- "XL"
- ],
- "price": 24,
- "currency": "GBP"
- },
- {
- "id": 422542,
- "brand": "Gap",
- "name": "Their other jacket",
- "photo": "jacket.jpg",
- "colors": [
- "red",
- "blue",
- "green",
- "gray"
- ],
- "sizes": [
- "S",
- "M",
- "L",
- "XL"
- ],
- "price": 23,
- "currency": "GBP"
- }
- ],
- "suits" : [
- {
- "id": 44344,
- "brand": "Moss Bros",
- "name": "The Three Piece",
- "photo": "suit.jpeg",
- "colors": [
- "red",
- "blue",
- "green",
- "gray"
- ],
- "sizes": [
- "S",
- "M",
- "L",
- "XL"
- ],
- "price": 24,
- "currency": "GBP"
- },
- {
- "id": 422542,
- "brand": "Gap",
- "name": "The Two Piece",
- "photo": "suit.jpeg",
- "colors": [
- "red",
- "blue",
- "green",
- "gray"
- ],
- "sizes": [
- "S",
- "M",
- "L",
- "XL"
- ],
- "price": 23,
- "currency": "GBP"
- }
- ]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement