Search code examples
reactjsreduxreact-hookspostcsstailwind-css

Unexpected Error Uncaught TypeError: setRender is not a function


Hope you all are doing alright. Anyways, I'm getting this:

    Uncaught TypeError: setRender is not a function
    at onClick (index.js:153:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)
    at invokeGuardedCallback (react-dom.development.js:4056:1)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4070:1)
    at executeDispatch (react-dom.development.js:8243:1)
    at processDispatchQueueItemsInOrder (react-dom.development.js:8275:1)
    at processDispatchQueue (react-dom.development.js:8288:1)
    at dispatchEventsForPlugins (react-dom.development.js:8299:1)
    at react-dom.development.js:8508:1
    at batchedEventUpdates$1 (react-dom.development.js:22396:1)
    at batchedEventUpdates (react-dom.development.js:3745:1)
    at dispatchEventForPluginEventSystem (react-dom.development.js:8507:1)
    at attemptToDispatchEvent (react-dom.development.js:6005:1)
    at dispatchEvent (react-dom.development.js:5924:1)
    at unstable_runWithPriority (scheduler.development.js:468:1)
    at runWithPriority$1 (react-dom.development.js:11276:1)
    at discreteUpdates$1 (react-dom.development.js:22413:1)
    at discreteUpdates (react-dom.development.js:3756:1)
    at dispatchDiscreteEvent (react-dom.development.js:5889:1)

While my component looks like

export default function ListAllRequests({ reload, setReload, setRender }) { 
 ///// HOOK STATES /////
///// OTHER CONSTANTS VARIABLES AND FUNCTIONS /////
return ( 

The Place where I'm getting the error:

  listRequests.map((request) => (
    <TableRow
       className={classes.tr}
       onClick={() => setRender(request._id)}
       key={request._id}
     >
  ))
)

So, is there any other way of using the setRender as a prop on the onClick event? Thanks in advance for your time and answer :)


Solution

  • At some point you are using the component like

    <ListAllRequests reload={something} setReload={somethingElse} setRender={thisIsYourProblem} />
    

    Either you are missing the setRender={thisIsYourProblem} there, or whatever you are passing in there is not a function.
    It's impossible to say more than that since you don't share that part of the code and state "this is the only code" in the comments.