小编Pix*_*lik的帖子

在 NextJS 中使用 StencilJS Web 组件时出现水合作用问题

我正在尝试让我的自定义表单域与 NextJS 很好地配合。但水分似乎有问题。

这是我的网络组件:

@Component({
  tag: 'test-checkbox',
  shadow: false,
})
export class TestCheckbox {
  @Prop() name: string;
  @Prop() value: boolean;
  @Prop() label: string;
  @Prop() innerValue: string;

  render() {
    const { value, name } = this;

    return (
      <div>
        <label htmlFor={this.name}>{this.label}</label>
        <input type="checkbox" name={name} id={name} checked={!!value} />
      </div>
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

我正在使用 Stencil ReactJS 包装器,因此 NextJS 中的代码将如下所示:

const Form = () => {
  const formRef = useRef();
  
  const handleInput = (e) => {
    ///
  };

  const handleSubmit = (e) => { …
Run Code Online (Sandbox Code Playgroud)

reactjs next.js stenciljs

6
推荐指数
1
解决办法
1405
查看次数

标签 统计

next.js ×1

reactjs ×1

stenciljs ×1