console.log(event.target['test'].value)
(данный пример от Вадим)<form onSubmit={
(event) => {
event.preventDefault()
console.log(inputCityValue)
}
}>
<Input value={inputCityValue} onChange={onChangeHandlerWrapper(setInputCityValue)}/>
<button type='submit'><span>Обновить данные</span></button>
</form>
+1 вариант
const input = useRef(null)
...
function successSubmit() {
input.current.value = ""
}
...
<Input ref={input } />
+2 вариант через state
const [state, setState] = useState({
inputValue: ''
})
...
function successSubmit() {
setState(prevState => {
return {
...prevState,
inputValue: ''
}
})
}
...
<Input
value={state.inputValue}
onInput={e => {
setState(prevState => {
return {
...prevState,
inputValue: e.target.value
}
})
}}/>
+3 Вариант изощренный - "до лучших времен"
function successSubmit() {
document.querySelectorAll('input').forEach(i => i.value = '')
}
npm install -g create-react-app
create-react-app my-app
render: (text, row, index) =>
...
onSelect={(e) => {
row.key = index
saveSelect()
}}>
...
function saveSelect(e) {
setState(prevState => {
return {
...prevState
}
})
}
{
test: /\.(png|svg|jpg|gif)$/,
use: [{
loader: 'file-loader',
options: {
name: f => {
let dirNameInsideAssets = path.relative(path.join(__dirname, 'src'), path.dirname(f));
return `${dirNameInsideAssets}/[name].[ext]`;
}
}
}],
},
import "./img/image.svg";
<img src="img/image.svg" alt=""/>