Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: morph/react ignore data slots from view's props #254

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions morph/react-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export default ({
fromViewsValidate: 1,
fromViewsAggregate: 1,
},
ignoredExpandedProps: [],
profile,
uses: [],
testIdKey: 'data-testid',
Expand Down
1 change: 1 addition & 0 deletions morph/react-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export default ({
fromViewsValidate: 1,
fromViewsAggregate: 1,
},
ignoredExpandedProps: [],
uses: [],
use(block, isLazy = false) {
if (isLazy) {
Expand Down
12 changes: 12 additions & 0 deletions morph/react/block-add-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ function addData(data, isAggregate, state) {
maybeDataValidate(data, state)
state.variables.push('})')
data.variables.isValidInitial = dataIsValidInitialName

state.ignoredExpandedProps.push('isValidInitial')
state.ignoredExpandedProps.push('isInvalidInitial')
}

if (data.uses.has('useDataIsValid')) {
Expand All @@ -102,6 +105,9 @@ function addData(data, isAggregate, state) {
}
state.variables.push('})')
data.variables.isValid = dataIsValidName

state.ignoredExpandedProps.push('isValid')
state.ignoredExpandedProps.push('isInvalid')
}
}

Expand All @@ -118,6 +124,8 @@ function addData(data, isAggregate, state) {
maybeDataFormatOut(data, state)
state.variables.push('})')
data.variables.onChange = dataChangeName

state.ignoredExpandedProps.push('onChange')
}

if (data.uses.has('useDataSubmit')) {
Expand All @@ -131,6 +139,8 @@ function addData(data, isAggregate, state) {
maybeDataContext(data, state)
state.variables.push('})')
data.variables.onSubmit = dataSubmitName

state.ignoredExpandedProps.push('onSubmit')
}

if (data.uses.has('useDataIsSubmitting')) {
Expand All @@ -144,6 +154,8 @@ function addData(data, isAggregate, state) {
maybeDataContext(data, state)
state.variables.push('})')
data.variables.isSubmitting = dataIsSubmittingName

state.ignoredExpandedProps.push('isSubmitting')
}

state.use('ViewsUseData')
Expand Down
1 change: 1 addition & 0 deletions morph/react/get-expanded-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default function getExpandedProps({
}) {
let slots = state.slots
.filter((slot) => !IGNORED_SLOTS.has(slot.name))
.filter((slot) => !state.ignoredExpandedProps.includes(slot.name))
.map((slot) => {
let maybeDefaultValue =
slot.defaultValue === false || ignoreDefaultValues
Expand Down