I Have problem with BLYNK_WRITE(V1) command

Dear All

I’m a new with BLYNK . I try to use command for send data from App to my Hardware with command BLYNK_WRITE(V1) code as below .When I upload code to my hardware it has error . It show as below

Arduino: 1.8.3 (Windows 7), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 115200, 4M (3M SPIFFS)"

C:\Users\TEX\Desktop\Arduino\Smart_Plug\Smart_Plug.ino: In function 'void loop()':

Smart_Plug:31: error: a function-definition is not allowed here before '{' token

     {

     ^

exit status 1
a function-definition is not allowed here before '{' token

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
     void loop()
    {
           Blynk.run();
       
           BLYNK_WRITE(V1)  {
              int virtualPinValue =  param.asInt(); 
          }
     
      }

How I can Solve it problem . Please someone help .Thank you very much

First, you don’t put this in the void loop() or any loop for that matter… it is a function all on its own so place it in your code as if it was a void, but it gets called by the associated widget’s state change.

Second, aside from applying the state parameter to the variable virtualPinValue, what is it supposed to do? You are missing the reaction code.

BLYNK_WRITE(V1) {
int virtualPinValue = param.asInt(); 
  // do something here with the virtualPinValue data, or do something(s) depending on the value of the parameter
}

Thank you very much