首页 > 解决方案 > 调用一个反应组件 - 作为一个函数

问题描述

我正在使用 quokka 并想从内部运行一个反应组件

I have a simple button


import React, { MouseEvent } from 'react';
type Props = {
  text: string
};

export const Button = ({ text }: Props) => {
  return <button> {text} </button>;
};

Button('hello') /*?*/ what goes in here?

我将其称为普通函数,但我试图找出如何传递道具?

上述元素的值

{ '$$typeof': Symbol(react.element),
  type: 'button',
  key: null,
  ref: null,
  props: { children: [ ' ', undefined, ' ' ] },
  _owner: null,
  _store: {} }

标签: reactjscomponentsreact-functional-componentquokka.js

解决方案


推荐阅读