<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>}
const bitmap = fs.readFileSync(file)
const base64Image = new Buffer(bitmap).toString('base64') // Получили изображение формата base64
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);