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

Radial gradient not working as expected with typescript #1962

Closed
Betanoir opened this issue May 21, 2024 · 2 comments
Closed

Radial gradient not working as expected with typescript #1962

Betanoir opened this issue May 21, 2024 · 2 comments
Labels
bug Something isn't working Stale Inactive issue

Comments

@Betanoir
Copy link

Betanoir commented May 21, 2024

  • three version: 0.164.1
  • @react-three/fiber version: 8.16.6
  • @react-three/drei version: 9.105.6
  • node version: 21.7.3
  • npm version: 10.2.1

Problem description:

I've used the documentation found in Drei's ReadMe file to create a radial gradient; however, I'm using typescript and an error is popping up no matter what I try to do.

The error only occurs when using the GradientType.Radial

Relevant code:

<mesh ref={ref} position={[props.x, props.y, 0]}>
    <boxGeometry args={[cubeSize, cubeSize, cubeSize]} />
    <meshBasicMaterial>
        <GradientTexture
            stops={[0, 0.8]}
            colors={['#0090ff', 'black']}
            size={1024}
            width={1024}
            type={GradientType.Radial}
             ^
        />
    </meshBasicMaterial>
</mesh>

The error that shows when hovering over type = {GradientType.Radial} is as follows:

Type 'GradientType.Radial' is not assignable to type 'undefined'.ts(2322)
GradientTexture.d.ts(12, 5): The expected type comes from property 'type' which is declared here on type 'IntrinsicAttributes & { stops: number[]; colors: string[]; attach?: string | undefined; size?: number | undefined; width?: number | undefined; type?: GradientType | undefined; innerCircleRadius?: number | undefined; outerCircleRadius?: string | ... 1 more ... | undefined; } & ExtendedColors<...>'
(property) type?: undefined

Suggested solution:

I have searched everywhere trying to find the solution and I've found nothing. The file mentioned in the error contains the following:

// GradientTexture.d.ts
import * as React from 'react';
export declare enum GradientType {
    Linear = "linear",
    Radial = "radial"
}
type Props = {
    stops: Array<number>;
    colors: Array<string>;
    attach?: string;
    size?: number;
    width?: number;
    type?: GradientType;
    innerCircleRadius?: number;
    outerCircleRadius?: string | number;
} & JSX.IntrinsicElements['texture'];
export declare function GradientTexture({ stops, colors, size, width, type, innerCircleRadius, outerCircleRadius, ...props }: Props): React.JSX.Element;
export {};

Any help would be appreciated!

@Betanoir Betanoir added the bug Something isn't working label May 21, 2024
@CodyJasonBennett
Copy link
Member

Maybe related to pmndrs/react-three-fiber#3270.

Copy link

Thank you for contributing! We’re marking this issue as stale as a gentle reminder to revisit it and give it the attention it needs to move forward.

Any activity, like adding an update or comment, will automatically remove the stale label so it stays on our radar.

Feel free to reach out on Discord if you need support or feedback from the community. This issue will close automatically soon if there’s no further activity. Thank you for understanding and for being part of the project!

@github-actions github-actions bot added the Stale Inactive issue label Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale Inactive issue
Projects
None yet
Development

No branches or pull requests

2 participants