Skip to content

Monorepo issue with nativewind #100

@ahmed-rezk-dev

Description

@ahmed-rezk-dev

Hello everyone. Hope you all having a good day.

I'm workin on a monorepo with shared components. Using rn-primitives

I created a new input package.

import * as React from 'react';
import { TextInput, type TextInputProps } from 'react-native';
import { cn } from '@shared/utils';

const Input = React.forwardRef<React.ElementRef<typeof TextInput>, TextInputProps>(
  ({ className, placeholderClassName, ...props }, ref) => {
    return (
      <TextInput
        ref={ref}
        className={cn(
          'web:flex h-12 native:h-14 web:w-full rounded-md border border-input bg-background px-3 web:py-2 text-base lg:text-sm native:text-lg native:leading-[1.25] text-foreground placeholder:text-muted-foreground web:ring-offset-background file:border-0 file:bg-transparent file:font-medium web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2',
          props.editable === false && 'opacity-50 web:cursor-not-allowed',
          className
        )}
        placeholderClassName={cn('text-muted-foreground', placeholderClassName)}
        {...props}
      />
    );
  }
);

Input.displayName = 'Input';

export { Input };

After building the package I use it as a dependencies within the same monorepo for apps/nextjs "@components/input": "workspace:*"

Which is sounds like is building fine

var Input = React.forwardRef(
  ({ className, placeholderClassName, ...props }, ref) => {
    return <import_react_native.TextInput
      ref={ref}
      className={(0, import_utils.cn)(
        "web:flex h-12 native:h-14 web:w-full rounded-md border border-input bg-background px-3 web:py-2 text-base lg:text-sm native:text-lg native:leading-[1.25] text-foreground placeholder:text-muted-foreground web:ring-offset-background file:border-0 file:bg-transparent file:font-medium web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2",
        props.editable === false && "opacity-50 web:cursor-not-allowed",
        className
      )}
      placeholderClassName={(0, import_utils.cn)("text-muted-foreground", placeholderClassName)}
      {...props}
    />;
  }
);
Input.displayName = "Input";

The problem is the classes is not showing up in the storybook when using it from the monorepo

<input placeholder="Write some stuff..." autocapitalize='sentences* autocomplete="on" autocorrect="on" dir="auto" rows="1" spellcheck="true" virtualkeyboardpolicy="auto" class="css-textinput-11aywtz r-placeholderTextColor-6taxm2">

But what is crazy that's is working fine if I used the any package after publishing it and install it from the npm registry.

Any idea how I can fix the issue?

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions