I'm making a portfolio and when I click the details button, I show the details about that specific work, what I want to do next is to hide de details when I don't want to see them anymore, for that o think I need to make my button a toggle button to hide and show the details.
I'm new to React and Redux, and I'm learning.
This is my GitHub Repository
https://github.com/hseleiro/PortBeta
You can start the server just making an npm start.
Once again the objective is to make a toggle button to hide and show de details, i stuck whit it and i cant go any further .
Could some one help me ?
This is my miristica.js
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { selectTrabalho } from '../../actions/index';
import TrabalhoMiristica from './detalhe_miristica';
class Miristica extends Component {
renderList(){
return this.props.trabalho_m.map((trabalho) => {
return (
<li>
<div className="row list-group">
<div className="col-md-4">
<img src={trabalho.img} />
</div>
<div className="col-md-8">
<h3>{trabalho.title}</h3>
<p>{trabalho.descricao}</p>
<button key={trabalho.id} onClick={() => this.props.selectTrabalho(trabalho)} type="button" className="btn btn-info">Detalhes</button>
<br/>
<br/>
<TrabalhoMiristica/>
</div>
</div>
</li>
);
})
}
render() {
return (
<ul className="list-group col-ms-4">
{this.renderList()}
</ul>
);
}
}
function mapStateToProps(state) {
return {
trabalho_m: state.trabalho_m
};
}
function mapDispatchToProps(dispatch) {
return bindActionCreators({ selectTrabalho: selectTrabalho }, dispatch)
}
export default connect(mapStateToProps, mapDispatchToProps)(Miristica);
This is my detail .js , the one i want to hide and show
import React, { Component } from 'react';
import { connect } from 'react-redux';
class TrabalhoMiristica extends Component {
render() {
if (!this.props.trabalho) {
return <div></div>;
}
return (
<div>
<div>{this.props.trabalho.tec}</div>
</div>
);
}
}
function mapStateToProps(state){
return {
trabalho: state.activeMiristica
};
}
export default connect(mapStateToProps)(TrabalhoMiristica);
If you guys need more information please tell me.
Thanks in advance