Skip to content

Commit

Permalink
给引出的组件删除memo
Browse files Browse the repository at this point in the history
  • Loading branch information
codebdy committed Dec 19, 2023
1 parent d75c77d commit aa38c4d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
10 changes: 5 additions & 5 deletions packages/fieldy/fieldy-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rxdrag/react-fieldy",
"version": "0.6.2",
"version": "0.6.5",
"type": "module",
"module": "index.ts",
"files": [
Expand All @@ -18,11 +18,11 @@
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
},
"devDependencies": {
"@rxdrag/eslint-config-custom": "workspace:*",
"@rxdrag/tsconfig": "workspace:*",
"@types/react": "^18.2.22",
"@types/react-dom": "^18.2.7",
"eslint": "^7.32.0",
"@rxdrag/eslint-config-custom": "workspace:*",
"@rxdrag/tsconfig": "workspace:*"
"eslint": "^7.32.0"
},
"peerDependencies": {
"react": "^18.2.0",
Expand All @@ -33,9 +33,9 @@
"dependencies": {
"@reduxjs/toolkit": "^1.9.3",
"@rxdrag/fieldy": "workspace:*",
"@rxdrag/fieldy-yup-validation": "workspace:*",
"@rxdrag/react-shared": "workspace:*",
"@rxdrag/shared": "workspace:*",
"@rxdrag/fieldy-yup-validation": "workspace:*",
"@types/react": "^18.2.22",
"@types/react-dom": "^18.2.7",
"lodash": "^4.17.21",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from "react"
import { memo } from "react"
import { Field } from "../Field"

//动态增加字段用这个,否则不要碰它
export const ArrayField = memo((
export const ArrayField = (
props: {
name: string,
value?: unknown[],
Expand All @@ -20,4 +19,4 @@ export const ArrayField = memo((
</Field>
</>
)
})
}
11 changes: 7 additions & 4 deletions packages/fieldy/fieldy-react/src/components/Field/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from "react"
import { memo } from "react"
import { XField } from "../XField"
import { useCreateFieldSchema } from "../XField/hooks/useCreateFieldSchema"
import { FieldType } from "@rxdrag/fieldy"
import { IYupValidateSchema } from "@rxdrag/fieldy-yup-validation"

//动态增加字段用这个,否则不要碰它
export const Field = memo((
export const Field = (
props: {
//数组时会使用number
name: string | number,
Expand All @@ -14,13 +14,16 @@ export const Field = memo((
defaultValue?: unknown,
children?: React.ReactNode,
type?: FieldType,
rules?: IYupValidateSchema,
}
) => {
const { name, value, initialValue, defaultValue, children, type } = props
const { name, value, initialValue, defaultValue, children, type, rules } = props
const fieldMeta = useCreateFieldSchema(name, type)
fieldMeta.validateRules = rules

return (
<XField fieldMeta={fieldMeta} initialValue={initialValue} value={value} defaultValue={defaultValue}>
{children}
</XField>
)
})
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { memo } from "react"
import React from "react"
import { Field } from "../Field"

//动态增加字段用这个,否则不要碰它
export const ObjectField = memo((
export const ObjectField = (
props: {
name: string | number,
initialValue?: unknown,
Expand All @@ -18,4 +18,4 @@ export const ObjectField = memo((
{children}
</Field>
)
})
}
2 changes: 1 addition & 1 deletion packages/fieldy/fieldy/src/classes/FieldImpl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ErrorListener, FieldState, IField, IFieldSchema, IFieldyEngine, IForm, Listener, SuccessListener, Unsubscribe, ValidateResult, ValidateStatus, ValueChangeListener } from "../interfaces/fieldy";
import { ErrorListener, FieldState, IField, IFieldSchema, IFieldyEngine, IForm, Listener, SuccessListener, Unsubscribe, ValidateStatus, ValueChangeListener } from "../interfaces/fieldy";
import { PropExpression } from "./PropExpression";
import { ValidationSubscriber } from "./ValidationSubscriber";
import { IValidateSchema, IValidationError } from "../interfaces";
Expand Down

0 comments on commit aa38c4d

Please sign in to comment.