React: Expected an assignment or function call and instead saw an expression

前端 未结 8 1357
一个人的身影
一个人的身影 2020-11-27 05:40

I am trying to fix this lint error at line const def = (props) => { in following sample code.

const propTypes = {
prop1: PropTypes.string,
pr         


        
8条回答
  •  一整个雨季
    2020-11-27 06:01

    Possible way is (sure you can change array declaration to getting from db or another external resource):

    const MyPosts = () => {
    
      let postsRawData = [
        { id: 1, text: 'Post 1', likesCount: '1' },
        { id: 2, text: 'Post 2', likesCount: '231' },
        { id: 3, text: 'Post 3', likesCount: '547' }
      ];
    
      const postsItems = []
      for (const [key, value] of postsRawData.entries()) {
        postsItems.push()
      }
    
      return (
          
    Posts: {postsItems}
    ) }

提交回复
热议问题