react vaadin components
1.0.0
警告このプロジェクトは、Vaadin/React Componentsを支持して非難されています
@hilla/react-componentsからインポートされたReactラッパーは(少なくともまだ)サーバー側のレンダリングをサポートしていませんが、SSRを無効にした動的なインポートとしてNext.JSプロジェクトで使用できます。import dynamic from "next/dynamic" ; export const Button = dynamic < import ( "@hilla/react-components/Button.js" ) . ButtonProps > ( ( ) => import ( "@hilla/react-components/Button.js" ) . then ( ( mod ) => mod . Button ) , { ssr : false , } ) ;アプリでlumoテーマを有効にするには:
if ( typeof window !== "undefined" ) { ( async ( ) => { const allImports = await import ( "@vaadin/vaadin-lumo-styles/all-imports.js" ) ; const style = document . createElement ( "style" ) ; Object . values ( allImports ) . forEach ( ( css ) => { style . append ( document . createTextNode ( css . toString ( ) ) ) ; } ) ; document . head . append ( style ) ; } ) ( ) ; }
React Vaadinコンポーネントは、VaadinコンポーネントのReact互換性のあるラッパーのセットです。
ラッパーはサーバー側のレンダリング可能であり、next.jsやgatsbyなどのフレームワークで使用できます。
ライブデモ(デモソース)
コンポーネントセットをインストールします
npm i react-vaadin-componentsインストールしたら、Reactアプリのコンポーネントをインポートして使用します
import 'react-vaadin-components/dist/css/core.css'
...
import {
TextField ,
Button ,
Notification
} from 'react-vaadin-components' ;
...
const [ name , setName ] = useState ( "" ) ;
...
< TextField
label = "Name"
clearButtonVisible
onValueChanged = { e => setName ( e . detail . value ) } >
</ TextField >
< Button
theme = "primary"
disabled = { ! name }
onClick = { e => Notification . show ( `Hello ${ name } ` ) } >
Say Hello
< / Button>