Generation

generate functionWed, 25 Jan 2023

анимация расширения блока на React

import React from "react"; import ReactDOM from "react-dom"; import "./styles.css"; class App extends React.Component { constructor() { super(); this.state = { value: "", text: "", isVisible: false }; this.handleChange = this.handleChange.bind(this); this.toggleVisibility = this.toggleVisibility.bind(this); } toggleVisibility() { this.setState(prevState => { return { isVisible: !prevState.isVisible }; }); } handleChange(e) { const { value } = e.target; this.setState(() => { return { value }; }); } render() { const { isVisible } = this.state; const text = isVisible ? "Hide text" : "Show text"; const btnText = isVisible ? "Hide" : "

Javascript
Generate More

Questions about programming?Chat with your personal AI assistant