decap-cms
decap-cms copied to clipboard
Fix(#7414): Fix React's bad setState() call warnings
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:
- A PropType warning regarding
ObjectPreview.field: This is declared asNode, but in reality an immutable map is passed. - A 404 error when trying to load assets while
visualEditingis turned on. I filed this as #7415 and included a quick fix here that simply disables visualEditing for the posts collection indev-test.