Closed joeweale closed 4 years ago
Hi,
I'm struggling to get a value from the components state inside the onconfigure handler. Everytime the state value is returned as its initial value not its current.
`export const Config = ({ sdk }: IProps) => { const [options, setOptions] = React.useState<Array>([]);
useEffect(() => { //state is being updated correcty console.log(options); }, [options]);
useEffect(() => { sdk.app.onConfigure(() => { //always initial value here console.log(options); }); setOptions([1, 2, 3]); }, []);
return
Anybody able to advise what I should be doing differently?
Thanks
Joe
Seems like with 3.12.1 I can work round it by settings the function on state change again.
https://github.com/contentful/ui-extensions-sdk/pull/283
Hi,
I'm struggling to get a value from the components state inside the onconfigure handler. Everytime the state value is returned as its initial value not its current.
`export const Config = ({ sdk }: IProps) => { const [options, setOptions] = React.useState<Array>([]);
useEffect(() => { //state is being updated correcty console.log(options); }, [options]);
useEffect(() => { sdk.app.onConfigure(() => { //always initial value here console.log(options); }); setOptions([1, 2, 3]); }, []);
return
Anybody able to advise what I should be doing differently?
Thanks
Joe