score:1
Accepted answer
i just pass a function oninputchange
to addimg component
. and in addimg component
calling that function
on input
change to pass input
value so that it can be set in the parent component.
app.js
function app() {
const [add, setadd] = usestate(false);
const [inputtext, setinputtext] = usestate('');
function click() {
setadd(true)
}
return (
<div classname="bigdiv">
<button onclick={click}>click</button>
<br /><br />
{
add &&
<>
<addimg oninputchange={(value) => setinputtext(value)} />
{inputtext}
</>
}
</div>
)}
addimg.js
export default function addimg({oninputchange}) {
return (
<div>
<input type="text" onchange={(e) => oninputchange(e.target.value)} />
</div>
)
}
Source: stackoverflow.com
Related Query
- How to pass input value from child to parent component react
- How to get input value from child component to my parent component on click of a button?
- How to pass value from parent component to child component (react)
- How to pass value from a child functional component to parent class component?
- How to update the correct state value in a parent component that gets its value from a child component using hooks in react?
- How to pass input values from a child Form component to the state of its parent component for submission with react hooks?
- how to pass input value from child to parent in functional componenent
- How to pass value from child to parent component
- How to pass value from functional child component to class parent component and save value to state?
- How to get input text's value and pass it from child to parent component?
- How to pass a value to my parent React component from input type?
- React How to get selected value from child component to parent component TypeScript
- how to get route param values of child component from parent component in app using React Router
- How can i update an Input field in Child component from the Parent Component
- How to pass value from child component to parent in TSX?
- How do I pass a boolean value from my React child to parent component
- How to send the value of variable from a child component to the parent component?
- How to pass value from child component(function based component )to parent component(class based component)
- How to display input box value from addImg.js (child component) to app.js (parent component) in react
- How to pass parent value to child on first render and change parent component value from Child?
- How to update and display the parent / list component from the child / detail component in ReactJS?
- How to change a value from parent component in a child component with useState React hook
- How to pass in memory json data from parent component to child component in react js and to display that in tabular form in child component
- How to update state in child component with context value from parent (class components)
- How do i pass a value from child component to parent component using function?
- How to get input textbox value in parent file from component in React Js
- How to pass the input value from child to parent in react typescript
- In React how to PROPERLY pass input value from child to parent
- How to pass data from child component to its parent in ReactJS?
- How to pass function as props from functional parent component to child
More Query from same tag
- Removing item from redux-stored list and redirect back to list - delay props evaluating?
- How do you route within a route in react
- How to simplify setTimeout in ReactJS
- post react form state to backend - using nodemailer
- React: How to render same page that includes multiple components and forms for 2 types of user with different permissions?
- Redirect to server route on ReactJS component using React Router V4
- How to toggle sort array data from state when click twice?
- How to access data from Context Provider using useContext?
- How should I structure a generic React/Typescript form component whose fields can be passed in as a type?
- How can i store the Ant Design's Time Picker time?
- How to set a state varibale for a dynamically rendered component in React
- Calling React JS from jsp
- how to move second component in react js?
- How to organise file structure of backend and frontend in MERN
- Reactjs - window.addEventListener hashchange only working when component loads initially
- How to route to an absolute path using react router?
- How should I update individual items' className onClick in a list in a React functional component?
- Import CSS in a react app
- How to link 'from outside' into Navigator (for example from a global footer)
- React How can I receive the 3h rain foreact from openweathermap (Identifier directly after number error)
- How pass a prop in my route from my component to a child component with an 'onClick'
- How to add import shortcuts - alias
- Text selection in React Slate no longer marked when focus changes to React Select
- I can't get checked row data with onRowSelected in Material UI DataGrid
- How to implement async authentication before redirect to login in React
- How do I create an interval API call in Nextjs?
- How to fetch an image in alt tag coming from a link
- ReactJS ValidateForm onSubmit requires a few clicks
- I just used react context, why does static context not work if I console on other components
- fetch nested object from array in JavaScript?