title: Can I use useReducer from outside component
body: <p>Now I'm trying to use useReducer to created a new way for management state and function but now found the problem is "Hooks can only be called inside of the body of a function component"
  Is there any way to solve this problem?</p>
  
  <pre><code>// App Component
  import React from "react";
  
  import { product, productDis } from "./ProductReducer";
  //{product} is state,  {productDis} is dispatch
  
  import { total } from "./TotalReducer";
  //{total} is state and i dont need {totalDis}
  
  
  const App = () =&gt; {
    return (
      &lt;div&gt;
        &lt;button onClick={()=&gt;productDis({type:'add',payload:'pen'})}&gt;add&lt;/button&gt;
        {product} {total}
      &lt;/div&gt;
    );
  };
  export default App;
  </code></pre>
  
  <pre><code>// ProductReducer Component
  import React, { useReducer } from 'react';
  import {totalDis} from './TotalReducer'
  //{totalDis} is dispatch and i dont need {total}
  
  
  export const [product, productDis] = useReducer((state, action) =&gt; {
      switch (action.type) {
          case "add": {
              const product_0 = 'pencil'
              const product_1 = `${action.payload} and ${product_0}`
              totalDis({
                  type:'total_add',
                  payload:'250'
              })
              return product_1;
          }
          default:
              return state;
      }
  }, []);
  </code></pre>
  
  <pre><code>// TotalReducer Component
  import React, { useReducer } from 'react';
  
  export const [total, totalDis] = useReducer((total, action) =&gt; {
      switch (action.type) {
          case "total_add": {
              const vat = action.payload*1.15
              return vat;
          }
          default:
              return total;
      }
  }, 0)
  </code></pre>
  
  <p>when i click the button on display It should be shown..." pen and pencil 287.5 "</p>
  
  <p>but it show "Hooks can only be called inside of the body of a function component"</p>
  
  <p>there any way to solve this problem? or i should back to nature?</p>