• Resolved cauemoraes91

    (@cauemoraes91)


    Whenever I write a useEffect() inside a component function of my block plugin, the edit page goes blank and the console logs the message:

    react_devtools_backend.js:4026 Error: Minified React error #321; visit https://reactjs.org/docs/error-decoder.html?invariant=321 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
        at Object.it (react-dom.min.js?ver=17.0.1:9:43163)
        at e.useState (react.min.js?ver=17.0.1:9:10899)
        at Prompt (Prompt.js:5:35)
        at N (element.min.js?ver=3dfdc75a0abf30f057df44e9a39abe5b:2:9552)
        at U (element.min.js?ver=3dfdc75a0abf30f057df44e9a39abe5b:2:10502)
        at N (element.min.js?ver=3dfdc75a0abf30f057df44e9a39abe5b:2:9284)
        at lr (blocks.min.js?ver=658a51e7220626e26a92a46af5c2e489:3:111294)
        at blocks.min.js?ver=658a51e7220626e26a92a46af5c2e489:3:137935
        at xn (blocks.min.js?ver=658a51e7220626e26a92a46af5c2e489:3:138073)
        at blocks.min.js?ver=658a51e7220626e26a92a46af5c2e489:3:139086

    The component:

    import React, { useState, useEffect } from "react";
    import axios from "axios";
    
    function Prompt(props) {
      const [data, setData] = useState({ hits: [] });
    
      useEffect(() => {
        const fetchData = async () => {
          const result = await axios(
            "http://my-site-test.local/wp-json/wp/v2/posts?_fields[]=title"
          );
    
          setData(result.data);
        };
    
        fetchData();
      }, []);
    
      console.log(data);
    
      return (
        <>
          <h5>Hello World</h5>
        </>
      );
    }
    
    export default Prompt;

    I tried to delete node_modules and reinstall to no avail…

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Error: Minified React error #321’ is closed to new replies.