Open mauroreisvieira opened 2 years ago
In my project, I'm using useView the problem is that the prop parameter is dynamic, initially, it's an empty object and only then it will be an object with all the props.
useView
const [props, setProps] = React.useState({}); React.useEffect(() => { // eslint-disable-next-line unicorn/consistent-function-scoping const aux = require('./code/button/demos/exampleKnobs'); setProps(aux.exampleKnobs.props); }, []); const { knobProps } = useView({ props });
from what I understand there is no useEffect that listens for config changes to reset knobsProps.
useEffect
config
knobsProps
I try to add something like that to reset settings but keep new props (NOT previous object):
useEffect(() => { dispatch({ type: Action.Reset, payload: { code: initialCode, props: config.props, providerValue: provider.value, }, }); }, [config.props]);
Another option is to return the function to updateProps, which can receive an object or updateAll which can receive new configurations.
updateProps
updateAll
In my project, I'm using
useView
the problem is that the prop parameter is dynamic, initially, it's an empty object and only then it will be an object with all the props.from what I understand there is no
useEffect
that listens forconfig
changes to resetknobsProps
.I try to add something like that to reset settings but keep new props (NOT previous object):
Another option is to return the function to
updateProps
, which can receive an object orupdateAll
which can receive new configurations.