React does not change the values in the same render. Either get a value with the filters and use in both places or use useEffect()
Jul 24, 2022
8
Level 2
Update react State and then inertia get request
i want to perform inertia get request after updating state
const [filters, setfilters] = useState(['comey']);
const addtag = (slug) => {
setfilters([slug]);
console.log(filters); // this give the new value as it should
Inertia.get('/', { tags: filters }) // but this perform a get request with initial state value , iwant it to update with the new state value
}
Level 2
I Found The Solution that i didnt use { preserveState: true } this is why it always the state refresh to the initial state
Please or to participate in this conversation.