react_vue_ts
react_vue_ts copied to clipboard
Trying to set default value for useState in React from another component.
I am passing a value from one component to another in React. Creating a updatable table from APIs on Database. The code will recognise the values in the new form when edit button is clicked, but when I try to pass them into the useState it is blank.
Here is where I passed them into new component:
export const EditEmployee=({open,onClose,empName,dep,Doj,Mail,ID})=>{
const[employeename, setemployeename] = useState('')
const[department, setdepartment] = useState('')
const[mail, setmail] = useState('')
const[doj, setdoj]= useState('')
I have tried setting useState to the variable, but it does not read it.
Here I set the default value on form and it reads it just fine.
Can this be done like I'm wanting to do this?
This is weird. I was able to use useState without any problem.
It is hard for me to understand your setup to figure out the issue. Could you provide me with a simple example where this is the case?