red-gold / react-social-network

Simple React Social Network
https://medium.com/@qolzam/create-social-network-by-react-js-fe60010a32e6
MIT License
489 stars 485 forks source link

Failed to compile #112

Closed TylerJKing closed 5 years ago

TylerJKing commented 5 years ago

When running 'yarn start' for this portion of the project, it gives "Starting the development server". After a while, it says "Compiling" before failing with the following error:

Failed to compile.

/home/tking/work/src/github.com/TylerJKing/react-social-network/src/components/post/PostComponent.tsx (415,50): Argument of type '(match: string, i: string) => Element' is not assignable to parameter of type '(match: string, index: number) => string | Element'. Types of parameters 'i' and 'index' are incompatible. Type 'number' is not assignable to type 'string'.


Below is what I have on line 415 in the postcomponent.tsx file:

    <CardContent className={classes.postBody}>
      <Linkify properties={{ target: '_blank', style: { color: 'blue' } }}>
        {reactStringReplace(body, /#(\w+)/g, (match: string, i: string) => (
          <NavLink
            style={{ color: 'green' }}
            key={match + i}
            to={`/tag/${match}`}
            onClick={evt => {
              evt.preventDefault()
              goTo!(`/tag/${match}`)
              setHomeTitle!(`#${match}`)
            }}
          >

Thanks!

Qolzam commented 5 years ago

Could you run the project by npm. Following below command to reinstall node modules too :

rm -rf node_modules && npm i && npm start
TylerJKing commented 5 years ago

Thanks, works now!