Skip to content

Commit

Permalink
feat: regression for unistyles not bound warning
Browse files Browse the repository at this point in the history
  • Loading branch information
jpudysz committed Jan 15, 2025
1 parent 0ead677 commit 46ba6c6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
6 changes: 3 additions & 3 deletions cxx/core/HostUnistyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ jsi::Function HostUnistyle::createAddVariantsProxyFunction(jsi::Runtime& rt) {
Variants variants = helpers::variantsToPairs(rt, arguments[0].asObject(rt));

helpers::enumerateJSIObject(rt, thisVal.asObject(rt), [this, &parser, &rt, &variants](const std::string& name, jsi::Value& value){
auto unistyle = this->_stylesheet->unistyles[name];

if (unistyle == nullptr) {
if (name == helpers::ADD_VARIANTS_FN || !this->_stylesheet->unistyles.contains(name)) {
return;
}

auto unistyle = this->_stylesheet->unistyles[name];

if (unistyle->dependsOn(UnistyleDependency::VARIANTS)) {
parser.rebuildUnistyle(rt, unistyle, variants, std::nullopt);
Expand Down
4 changes: 3 additions & 1 deletion src/core/createUnistylesElement.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export const createUnistylesElement = (Component: any) => React.forwardRef((prop
ref={(ref: unknown) => {
storedRef.current = ref
passForwardedRef(props, ref, forwardedRef)
maybeWarnAboutMultipleUnistyles(props, Component.displayName)

// @ts-ignore we don't know the type of the component
maybeWarnAboutMultipleUnistyles(props.style, Component.displayName)
}}
/>
)
Expand Down
2 changes: 2 additions & 0 deletions src/core/createUnistylesImageBackground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export const createUnistylesImageBackground = (Component: typeof ImageBackground

// @ts-expect-error we don't know the type of the component
maybeWarnAboutMultipleUnistyles(props.style, 'ImageBackground')
// @ts-ignore we don't know the type of the component
maybeWarnAboutMultipleUnistyles(props.imageStyle, 'ImageBackground')

return (
<Component
Expand Down
10 changes: 5 additions & 5 deletions src/core/withUnistyles/withUnistyles.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
const narrowedProps = props as PropsWithUnistyles
const NativeComponent = Component as ComponentType

// @ts-ignore we don't know the type of the component
maybeWarnAboutMultipleUnistyles(narrowedProps.style, `withUnistyles(${Component.displayName ?? 'Unknown'})`)
// @ts-ignore we don't know the type of the component
maybeWarnAboutMultipleUnistyles(narrowedProps.contentContainerStyle, `withUnistyles(${Component.displayName ?? 'Unknown'})`)

const { mappingsCallback, addDependencies } = useDependencies(({ dependencies, updateTheme, updateRuntime }) => {
const listensToTheme = dependencies.includes(UnistyleDependency.Theme)
// @ts-expect-error - this is hidden from TS
Expand All @@ -50,11 +55,6 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
})

useEffect(() => {
// @ts-ignore
maybeWarnAboutMultipleUnistyles(narrowedProps.style, `withUnistyles(${Component.displayName ?? 'Unknown'})`)
// @ts-ignore
maybeWarnAboutMultipleUnistyles(narrowedProps.contentContainerStyle, `withUnistyles(${Component.displayName ?? 'Unknown'})`)

const styleSecrets = getSecrets(narrowedProps.style)
const contentContainerStyleSecrets = getSecrets(narrowedProps.contentContainerStyle)

Expand Down

0 comments on commit 46ba6c6

Please sign in to comment.