react pass prop to parent
//Form (Parent)
import React, { useState, Component } from 'react';
import Input from '../../shared/input-box/InputBox'
const Form = function (props) {
const [value, setValue] = useState('');
const onchange = (data) => {
setValue(data)
console.log("Form>", data);
}
return (
<div>
<Input data={value} onchange={(e) => { onchange(e) }}/>
</div>
);
}
export default Form;
//Input Box (Child)
import React from 'react';
const Input = function (props) {
console.log("Props in Input :", props);
const handleChange = event => {
props.onchange(event.target.value);
}
return (
<div>
<input placeholder="name"
id="name"
onChange= {handleChange}
/>
</div>
);
}
export default Input;
Also in JavaScript:
- js insert in array
- javascript combine objects
- ng-container vs ng-template
- media queries generator script
- angular 4200 on ec2 access is localhost
- express js continous GET /json/version
- exploding string with comma using jquery
- switch in react
- react create array
- javascript replace spaces with br
- how to write a program that alerts the current month in words in javascript
- Installation failed, reverting ./composer.json and ./composer.lock to their original content.
- javascript function return boolean
- angular event scroll end of page
- if statement javascript
- javascript redirect to homepage
- js remove json value duplicates
- decode ways javascript
- fullscreen electron
- js array delete last
- urlencode jquery
- price range slider bootstrap 4
- 14. Write a JavaScript function to find the difference of two arrays. Test Data : console.log(difference([1, 2, 3], [100, 2, 1, 10])); ["3", "10", "100"]
- autocomplete react vscode