How to create editable global variables?
Answered
Minskin posted this in #help-forum
MinskinOP
Hi everyone! I have two variables in one of my functions, but I just realized I will need to access them inside other functions aswell. Im not sure how I would be able to do that?
Here are the two variables I want to have access to:
Here are the two variables I want to have access to:
function Template(props: ProjectProps)
{
const [selectedImage, setSelectedImage] = useState("");
const [showFullscreenImage, setShowFullscreenImage] = useState(false);
}Answered by Minskin
Nvm, I managed to solve it by creating my function inside the function that holds the variables. Like this:
function Template(props: ProjectProps)
{
const [selectedImage, setSelectedImage] = useState("");
const [showFullscreenImage, setShowFullscreenImage] = useState(false);
ContentImage = (image: string, justiy: string) => {...}
}1 Reply
MinskinOP
Nvm, I managed to solve it by creating my function inside the function that holds the variables. Like this:
function Template(props: ProjectProps)
{
const [selectedImage, setSelectedImage] = useState("");
const [showFullscreenImage, setShowFullscreenImage] = useState(false);
ContentImage = (image: string, justiy: string) => {...}
}Answer