nss-day-cohort-46 / How-to-Ask-for-Help

0 stars 0 forks source link

HELP my useHistory() function seems to be breaking in the meat of my react bundle #91

Closed jakefroeb closed 3 years ago

jakefroeb commented 3 years ago

Ticket MUST be completed before getting help from an instructor

Name: Jake Froeb

Breakout Room: garment of illusions

Have you searched the other issue tickets? If not, do that first.

REQUIRED Add Tags to Issue Ticket and Assign to Project Board

REQUIRED Describe your issue:

calling useHistory() is breaking my code

REQUIRED Copy/paste any error messages that appear:

Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app

REQUIRED: What have you tried? Tell us everything you have tried.

I have tried running the

npm i --save react-router-dom

REQUIRED: Copy/paste link TO THE FILE on your branch that you are having issues with

https://github.com/nss-day-cohort-46/reactive-nutshell-garment-of-illusions-1/tree/jhf-tasks-postTask/src/components/tasks

Code Snippet

import { useHistory } from "react-router-dom"
import React from "react"

export const TaskList = () => {

    const history = useHistory()

    return (
        <>
            <button onClick={()=> history.push("/tasks/create")}>Add Task</button>
        </>
    )
}
ajawashington commented 3 years ago

@sageklein @jisie test example

Scott47 commented 3 years ago

@ajawashington comments test for c46-help-repo

Scott47 commented 3 years ago

@jakefroeb ignore this @mention.

Scott47 commented 3 years ago

Was not calling function correctly in JSX.