Skip to content

Instantly share code, notes, and snippets.

@larien
Created November 27, 2018 17:25
Show Gist options
  • Save larien/964eabe401c1d8b7793d239643ea941b to your computer and use it in GitHub Desktop.
Save larien/964eabe401c1d8b7793d239643ea941b to your computer and use it in GitHub Desktop.
caralho de bug chato da porra
import React, { Component } from 'react'
import { loadReviews } from '../../../redux/actions/actions'
import { connect } from 'react-redux'
const mapStateToProps = state => {
return {
reviews: state.reviews.reviews
}
}
export class Reviews extends Component {
componentWillReceiveProps(nextProps){
}
componentWillMount(){
this.props.loadReviews()
}
render() {
const reviews = this.props.reviews
console.log(reviews)
reviews.reverse().map((review)=>
<div className="card">
<div className="data">
<h3 className="title"><a href={`/reviews/${review._id}`}>{review.title}</a></h3>
</div>
</div>
)
return (
<div>
<p>Hello, Reviews!</p>
{ reviews }
</div>
)
}
}
export default connect(mapStateToProps, { loadReviews })(Reviews);
@juunegreiros
Copy link

import React from 'react'
import { loadReviews } from '../../../redux/actions/actions'
import { connect } from 'react-redux'

const mapStateToProps = state => {
    return ({
        reviews: state.reviews.reviews
    })
}

const mapDispatchToProps = {
    loadReviews
}

export class Reviews extends Component {
   constructor(props) {
      super(props)

     this.props.loadReviews()
   }

  render() {
      const reviews = this.props.reviews
      console.log(reviews)
      reviews.reverse().map((review)=>
      <div className="card">
          <div className="data">
            <h3 className="title"><a href={`/reviews/${review._id}`}>{review.title}</a></h3>
          </div>
        </div>
      )
    return (
      <div>
        <p>Hello, Reviews!</p>
        { reviews }
      </div>
    )
  }
}

export default connect(mapStateToProps,mapDispatchToProps)(Reviews);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment