<input type="text" name="name" minlength="6" maxlength="10" size="10">
constructor(props) {
super(props);
this.showText = this.showText.bind(this);
this.showText2 = this.showText2.bind(this);
};
showText2(e) {
this.setState({ text2: e.target.value });
}
onFocusOff = (e) => {
if(this.state.text2.length < 6){
this.setState({ alert: "Не менее 6 символов" });
}
}
<input defaultValue={this.showText} onBlur={this.onFocusOff} onInput={this.showText2} />
{this.state.alert && <p>{this.state.alert}</p>}
import React from 'react';
import './App.css';
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
text: '',
count: 0,
}
}
showText = () => {
console.log('button work');
this.setState({ text: 'button work' });
}
showCount = () => {
this.setState({ count: this.state.count + 1});
}
render() {
return (
<div>
<button onClick={this.showText}>Push1</button>
<p>{this.state.text}</p>
<button onClick={this.showCount}>Count</button>
<p>{this.state.count}</p>
</div>
)
}
}
export default App;
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
text: '',
count: 0,
}
}
showText = () => {
console.log('button work');
this.setState({ text: 'button work' });
}
showCount = () => {
this.setState({ count: '0' });
}
render() {
return (
<div>
<button onClick={this.showText}>Push1</button>
<p>{this.state.text}</p>
<button onClick={this.showCount}>Count</button>
<p>{this.state.count}</p>
</div>
)
}
}
import styled, { css, createGlobalStyle } from 'styled-components'
export const GlobalStyle = createGlobalStyle`
.comPlainTextContentEditable {
-webkit-user-modify: read-write-plaintext-only;
cursor: text;
}
`
export const CustomPopoverContainer = styled.div`
position: absolute;
right: 10px;
flex-flow: column nowrap;
`
//и т.д.
let componentDidMount = JSON.parse(localStorage.getItem("comms")) || [];
let componentDidMount = localStorage.getItem("comms");
componentDidMount = JSON.parse(componentDidMount);
{
step: 1, // текущий шаг, по умолчанию будет первый
name: '', // и остальные поля для заполнения.
phone: '',
...
}
{el && <span>{el}</span>}
<TrainBox2 data={{title=" something text", term : "some term", term2 : "some term 2"}} />
<div className="one_floor_top">
<div className="floor_big">{props.data.title}</div>
<div className="floor_small">{props.data.term}</div>
<div className="floor_big">{props.data.title}</div>
<div className="floor_small">{props.data.term2}</div>
</div>
<TrainBox2
data={{title=" something text", term : "some term"}}
data2={{title=" something text", term : "some term"}}
/>
<div className="one_floor_top">
<div className="floor_big">{props.data.title}</div>
<div className="floor_small">{props.data.term}</div>
<div className="floor_big">{props.data2.title}</div>
<div className="floor_small">{props.data2.term}</div>
</div>