Answer the question
In order to leave comments, you need to log in
How to get input value during onSubmit event?
Can you tell me how to get input values?
Here, of course, an incorrect assignment occurs, because event refers to the form, and not to the input.
const payload = event.target.value
Full code:
import React from 'react'
import Input from '../../UI/Input/Input';
import Button from '../../UI/Button/Button';
import classes from './Main.module.css'
export default class Main extends React.Component {
submitHandler = (event) => {
event.preventDefault()
const {getValueInput} = this.props
const payload = event.target.value
getValueInput(payload)
}
render() {
return (
<div className={classes.main}>
<div className={classes.main_inner}>
<div className={classes.form_outer}>
<form onSubmit={this.submitHandler}>
<Input />
<Button>Добавить</Button>
</form>
</div>
</div>
</div>
)
}
}
Answer the question
In order to leave comments, you need to log in
If I understand you correctly, then:
Add state,
state = {
inputEntry: '',
}
submitHandler
replace const payload = event.target.value
with const payload = this.state.inputEntry
handleInputChange = (e) => {
this.setState({inputEntry: e.target.value})
};
In your case, the regular season cannot be compiled because the minimum number of elements in it is to list stupidly all domains (msk|spb|uk|kz)
, and so on.
Or, for example, like this, (.+[^/])
one or more characters but not a slash (that is, select everything up to the first slash)
RedirectMatch ^(.+[^/])/link1$ http://vash-site.ru/$1/link2
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question