-
-
Notifications
You must be signed in to change notification settings - Fork 243
Closed
Description
I ran into this issue when using the file-upload package, but I think it applies to all components. The code examples
const api = fileUpload.connect(state, send, normalizeProps)
returns a new api object every time a component renders. Ideally this would be memoized so child components can optimize their rendering if they so choose. Memoizing the callback functions separately would also be useful. I ran into an issue where I had code that updated the machine's state if a parent component provided a new value
useEffect(() => {
api.setFiles(value)
}, [value, api.setFiles])
Because api.setFiles is new every time the component renders, the useEffect gets run (even when the value is unchanged).
I think adding memoization into the connect methods would be really helpful. This probably means the connect methods need to become hooks in React.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels