0

I am brand new to React and am having a hard time understanding the error I am receiving. I managed to fix some other errors of this type, but this specific one has me lost. In a typescript file, I have:

export interface FarmsProps {
     tokenMode?: boolean
}

and then further down

const Farms: React.FC<FarmsProps> = (farmsProps) => {
  const { path } = useRouteMatch()
  const TranslateString = useI18n()
  const farms = useFarms();
  const prices = usePrices()
  const farmsLP = useFarms()
  const cakePrice = usePriceCakeBusd()
  const bnbPrice = usePriceBnbBusd()
  const { account, ethereum }: { account: string; ethereum: provider } = useWallet()
  const { tokenMode } = farmsProps;
  const [modalOpen, setModalOpen] = useState(true)
  const handleModal = async () => {
    setModalOpen(!modalOpen)
  }

I get the following error when compiling:

Failed to compile.

src/views/LiqPools/Farms.tsx
  Line 26:6:  'tokenMode' PropType is defined but prop is never used  react/no-unused-prop-types

Search for the keywords to learn more about each error.

Any guidance is much appreciated.

gogo
  • 53
  • 1
  • 12
  • Looks like a warning from your linter? You're creating the `tokenMode` variable, but it doesn't look like you're actually using it anywhere. Just delete `const { tokenMode } = farmsProps;` or use it somewhere. – sallf Mar 02 '22 at 18:48
  • @sallf I tried deleting the line but it doesn't solve the issue. It is a linter error, I managed to fix some previous ones by deleting lines but not this one. This React app is forked which is why Im struggling to understand whats going on – gogo Mar 02 '22 at 18:50
  • It shouldn't actually be breaking your code. Maybe try and [disable the rule](https://stackoverflow.com/questions/30948970/how-to-disable-eslint-react-prop-types-rule-in-a-file)? – sallf Mar 02 '22 at 18:51
  • @sallf I tired that as well; they have react/prop-types set to "off" in the linter file with a note saying they dont use prop-types. I set it to 0 but no luck. I also added /* eslint-disable react/prop-types */ to the top of my file, still no difference – gogo Mar 02 '22 at 18:55
  • The one to disable is `react/no-unused-prop-types` not `react/prop-types`. You should also be able to [turn linter errors into warnings](https://stackoverflow.com/questions/48249564/ignore-or-prevent-eslint-errors-from-breaking-the-build-in-a-react-project-crea), so they don't break your build. – sallf Mar 02 '22 at 19:53

1 Answers1

0

In my case, I have just added a line into .eslintrc file at the rules object.

"rules": {"react/no-unused-prop-types": 0}