I am having trouble with the setState of objects. My interface definition is as follows;
export interface IProjectData {
Id?: string,
Description?: string,
ProjectState?: string,
}
I access the parameter I sent with RootStackParamList as follows.
function ProjectScreen({ route, navigation }: ProjectProps) {
const [project, setProject] = useState<IProjeData>(null)
useEffect(() => {
const sProject = JSON.stringify(route.params.project)
let myProject: IProjeData = JSON.parse(sProject)
console.log('myProject: ')
console.log(myProject)
setProject(myProject)
console.log('Project: ')
console.log(project)
}, [])
return (
...
...
)}
Consol output is as follows. Where am I going wrong? Why can't I assign a value to project?
myProject:
{Id: "bd7acbea", Description"My Test Project", ProjectState"25/25"}
Project:
null