decap-cms icon indicating copy to clipboard operation
decap-cms copied to clipboard

Fix(#7414): Fix React's bad setState() call warnings

Open fgnass opened this issue 10 months ago • 0 comments

This PR fixes the warnings React logs to the console when an asset preview is shown for the first time (see #7414).

The issue is caused because getAsset dispatches an action, which in turn triggers a state update. I haven't done any Redux in a while, so there might be better patterns to fix this, but this at least does the trick.

While fixing this, I stumbled over two other problems in the console logs:

  1. A PropType warning regarding ObjectPreview.field: This is declared as Node, but in reality an immutable map is passed.
  2. A 404 error when trying to load assets while visualEditing is turned on. I filed this as #7415 and included a quick fix here that simply disables visualEditing for the posts collection in dev-test.

fgnass avatar Feb 25 '25 14:02 fgnass