I've an issue in my project
I added a component in astro file
...
<div id="commit-history-container" class="mt-4 overflow-hidden transition-all duration-300 max-h-0">
<CommitHistory client:load/>
</div>
...
and add initialize function to initialize state variable that will be used in commitHistory component.
<script>
import {initializeProjectState} from ...
document.addEventListener("astro:page-load", () => {
initializeProjectState();
...
}
</script>
in CommitHistory.jsx file
...
useEffect(() => {
const addMaintainerBadge = () => {
const configData = loadConfigData();
if (configData) {
const authors = configData.authorGithubNames.map(name => name.toLowerCase());
setAuthors(authors);
} else {
console.log("Can not read config data.");
}
}
addMaintainerBadge();
}, []);
...
as you can see in CommitHistory component, I initialize authors by using loadConfigData function and those configData is initialized by running initializeProjectState function.
but when I run the project, configData is initialized but in the commithistory component, configdata is undefined
I think this is because CommitHistory component is rendered before running initialize function
how can I solve this?