首页
看点啥
插画图片
首页 科技看点 informed:实践指南

informed:实践指南

2026-09-13 0

面对实际交付,我看informed的重点不在星标,而在这项能力:用于在 React 应用程序中构建强大表单的轻量级框架和实用程序。把它放到界面与前端开发流程中,最容易暴露的是视觉还原、交互状态和响应式细节容易遗漏,不能只看演示是否顺利。先选一个包含多状态的真实组件完成实现更稳妥;过程中要观察尺寸、状态、可访问性、资源和不同视口表现,失败也应能解释原因。整体来看,它适合愿意逐状态验收界面质量的前端团队拿来做对照测试,最终决定仍应回到真实结果和维护状态。

消息灵通

简介

向您使用过的最好的 React 表单库问好! Informed 是一个广泛、简单且高效的解决方案,用于在 React 中创建基本到复杂的表单。开箱即用,您可以获取和操作值、验证字段、创建自定义输入、多步骤表单、数组字段等等!

哦还有YES WE USE HOOKS!

开始使用

使用 npm 安装

npm install --save informed

实例/文档

它能做什么?

你自己看看吧。

默认情况下,它带有由 inform 控制的本机 dom 输入。

import { Form, Input, Select, Checkbox, Relevant, Debug } from 'informed';

const onSubmit = ({ values }) => console.log(values);

const ExampleForm = () => (
  
formState.values.married}> );

功能列表

informed 旨在支持许多重要功能

创建你自己的领域

但是如果您不想要开箱即用的东西怎么办?

没问题,请看下面的例子!

import { useForm, useField, Relevant, FormState } from 'informed';

// Step 1. Build your form component ---------------------

const Form = ({ children, ...rest }) => {
  const { formController, render, userProps } = useForm(rest);

  return render(
    
{children}
); }; // Step 2. Build your input components -------------------- const Input = props => { const { render, informed, userProps, ref } = useField({ type: 'text', ...props }); const { label, id, ...rest } = userProps; return render( <> ); }; const Checkbox = props => { const { render, informed, userProps, ref } = useField({ type: 'checkbox', ...props }); const { label, id, ...rest } = userProps; return render( <> ); }; const ErrorInput = props => { const { render, informed, userProps, fieldState, ref } = useField({ type: 'text', ...props }); const { label, id, ...rest } = userProps; const { showError } = fieldState; const style = showError ? { border: 'solid 1px red' } : null; return render( <> {showError && {fieldState.error}} ); }; const Select = props => { const { render, informed, userProps, ref } = useField({ type: 'select', ...props }); const { label, id, children, ...rest } = userProps; return render( <> ); }; // Step 3. Build your forms! --------------------------- const onSubmit = ({ values }) => console.log(values); const ExampleForm = () => (
formState.values.married}> );
喜欢(0)

上一篇

ngx-virtual-scroller:实践指南

ngx-virtual-scroller:实践指南

下一篇

layering-cache:实践指南

layering-cache:实践指南
猜你喜欢