tachyon-ops / react_vue_ts

Vuera TS lib
19 stars 1 forks source link

Trying to set default value for useState in React from another component. #8

Open strikerkenpo opened 10 months ago

strikerkenpo commented 10 months ago

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.

setemployeename(e.target.value)}/> Can this be done like I'm wanting to do this?
tachyon-ops commented 7 months ago

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?