Skip to content

v2中生命周期钩子不能嵌套使用 #1226

Answered by janryWang
NexxLuo asked this question in Q&A [2.x]
Discussion options

You must be logged in to vote

第一个问题的解法

import React from "react";
import {
  createForm,
  onFieldReact
} from "@formily/core";
import { FormProvider, createSchemaField } from "@formily/react";
import { Input, Button, Card } from "antd";
import "antd/lib/input/style";

const form = createForm({
  effects() {
    onFieldReact("input", (field) => {
      if (!form.mounted) return;
      const visible = field.visible;
      field.query("card").take((card) => {
         card.visible = visible;
      });
    });
  }
});

const SchemaField = createSchemaField({
  components: {
    Input,
    Card
  }
});

export default () => (
  <FormProvider form={form}>
    <SchemaField
      schema={{
        type: "object",
        pro…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@NexxLuo
Comment options

@janryWang
Comment options

@NexxLuo
Comment options

Answer selected by janryWang
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants