title: How to pass a value to a variable from React file to node server file
body: <p>I am a beginner in React and node my question is how to pass the value to a variable from react file to node server file onclick <br></p>
  <p>my code in (React) hello.js file</p>
  <pre><code>import React, { Component } from 'react';
  
  class APP extends Component {
      constructor(props) {
          super(props);
          this.state = {
            value: null,
          };
      }
      
    render() {
      return (
        &lt;div className=&quot;greet&quot; &gt;
          
          &lt;div className=&quot;hello&quot; onClick={() =&gt; this.setState({value: 'Hello'})}&gt;
            &lt;h4&gt;Hello&lt;/h4&gt;
          &lt;/div&gt;
  
          &lt;div className=&quot;hi&quot; onClick={() =&gt; this.setState({value: 'Hi'})}&gt;
              &lt;h4&gt;Hi&lt;/h4&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
        
      );
    }
  }
  
  export default APP;
  
  
  </code></pre>
  <p>(Nodejs) server.js file</p>
  <pre><code>const http = require('http')
  const path = require('path')
  const express = require('express')
  const socketIo = require('socket.io')
  const needle = require('needle')
  const config = require('dotenv').config()
  const TOKEN = process.env.TWITTER_BEARER_TOKEN
  const PORT = process.env.PORT || 8000
  
  const app = express()
  
  const server = http.createServer(app)
  const io = socketIo(server)
  
  app.get('/', (req, res) =&gt; {
    res.sendFile(path.resolve(__dirname, '../', 'client', 'index.html'))
  })
  
  
  
  const rules = [onclick value]
  </code></pre>
  <p>when on clicking the Hello div in react file the value &quot;hi&quot; should be passed to a const rules in node server file like wise when clicking the hi div the &quot;hi&quot; value should be passed to a variable</p>