英文:
How to use React components in Qwik?
问题
可以在 Qwik 框架中使用 React 组件库中的 React 组件吗?我正在尝试使用我已安装的依赖项中的组件,但它们是用 React 编写的。
英文:
Is it possible to use React components from a component library in Qwik framework?
I'm trying to use components from a dependency that i have installed but they are written in React.
答案1
得分: 1
In short: you can but should avoid it if you can and only should use it as a migration strategy. For more information: Use qwikify$() as a migration strategy
QwikReact allows you to use React components in Qwik, including the whole ecosystem of component libraries.
You need to install:
npm run qwik add react
The qwikify the component you want to use:
/** @jsxImportSource react */
import { qwikify$ } from '@builder.io/qwik-react';
import { ReactComponent } from '@react/component/library';
export const Component = qwikify$(ReactComponent);
> Important: You need to import /** @jsxImportSource react */ at the top
> of your file, this is an instruction to the compiler to use React as
> the JSX factory.
For more information see Qwik React.
英文:
In short: you can but should avoid it if you can and only should use it as a migration strategy. For more information: Use qwikify$() as a migration strategy
QwikReact allows you to use React components in Qwik, including the whole ecosystem of component libraries.
You need to install:
npm run qwik add react
The qwikify the component you want to use:
/** @jsxImportSource react */
import { qwikify$ } from '@builder.io/qwik-react';
import { ReactComponent } from '@react/component/library';
export const Component = qwikify$(ReactComponent);
> Important: You need to import /** @jsxImportSource react */ at the top
> of your file, this is an instruction to the compiler to use React as
> the JSX factory.
For more information see Qwik React.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论