Description
I have a component:
export function Actions(props) {
const [isDisabled, setDisabledState] = useState(true);
return (
<TopToolbar {...sanitizeListRestProps(props)}>
<Button
onClick={() => {
setDisabledState(!isDisabled);
}}
label="Toggle state"
>
<ClearAllIcon />
</Button>
<CreateButton disabled={isDisabled} label="Create Patient" />
</TopToolbar>
);
}
I expect the disabled state to toggle when after clicking the Toggle state
button. Instead nothing happens, the CreateButton doesn't rerender.
This looks like a similar issue faced in this ticket. I imagine the solution would be to add an additional check to see if the disabled prop has changed.
I'm not too sure if this is a specific design choice to avoid this rerendering when this particular prop changes, but I can't see why it's not supported given this example in the docs shows the disabled
attribute being used.
I've recreated this in the codesandbox: https://codesandbox.io/s/romantic-keldysh-bh10v?file=/src/posts/PostList.js
If you guys are fine with this, I can quickly get a PR going. I imagine it's a simple one line change
Edit: I ended up making an MR for this
Activity