React - How to export a pure stateless component

前端 未结 4 1275
臣服心动
臣服心动 2021-01-31 00:58

How can I export a stateless pure dumb component?

If I use class this works:

import React, { Component } from \'react\';

export default class Header ext         


        
4条回答
  •  攒了一身酷
    2021-01-31 01:37

    You can also use a function declaration instead of assignment:

    export default function Header() {
        return 
    Header
    }

    In your example, you already use curly brackets and return so this is apparently matching with your needs with no compromise.

提交回复
热议问题