Answer the question
In order to leave comments, you need to log in
How to make a dropdown block on click (React Redux)?
class CompanyPage extends React.Component {
static propTypes = {
dispatch: PropTypes.func.isRequired
};
constructor(props) {
super(props);
this.state = {
info: {
display: 'none !important'
}
};
}
onBtnClickHandler(e) {
e.preventDefault();
var block = document.querySelector('.selected-company-info__text');
block.setState({
info: { display: 'block !important' }
});
}
render () {
const {
props: { },
state: { info }
} = this;
const style = {
info: {
block: info.block
}
};
return(
<a
href="javascript://"
className="button button--white button--center"
onClick={this.onBtnClickHandler}>
УЗНАТЬ БОЛЬШЕ О ...
</a>
</div>
<div style={style.block} className="selected-company-info__text visible-tablet disable-mobile">
some text
</div>
);
}
}
export default CompanyPage;
Answer the question
In order to leave comments, you need to log in
Oh lord.
componentWillMount() {
this.setState({buttonToggle: true})
}
handleClick() {
this.setState({buttonToggle: !this.state.buttonToggle})
}
render() {
.....
<div style={{display: (this.state.buttonToggle ? 'block' : 'none')}}></div>
....
}
Ну и собственно зачем document.querySelector там где это не надо и вложенность стилей странная у вас, запутаетесь же
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question