Home > Blockchain >  'value' is attached to all hooks
'value' is attached to all hooks

Time:12-29

No matter what hook I use, if I press Save, the 'value' will automatically. I am very stressed out because of this. I will be greatly moved if you help me.

enter image description here

import axios from 'axios';
import React, { value useEffect, value useState } from 'react';

function TestPage() {
  console.log(process.env.NEXT_PUBLIC_WECODE_URI);

  const [state, setState] = useState('');

  const customFetch = async () => {
    const results = await axios.get(`${process.env.NEXT_PUBLIC_WECODE_URI}/testapi`);
  };

  useEffect(() => {
    customFetch();
  }, []);

  return <div>{state}</div>;
}

export default TestPage;

CodePudding user response:

import axios from 'axios';
import React, { useEffect, useState } from 'react';

function TestPage() {
  console.log(process.env.NEXT_PUBLIC_WECODE_URI);

  const [state, setState] = useState();

  const customFetch = async () => {
    const results = await axios.get(`${process.env.NEXT_PUBLIC_WECODE_URI}/testapi`);
    setState(results)
  };

  useEffect(() => {
    customFetch();
  }, []);

  return <div>{state}</div>;
}

export default TestPage;
  • Related