ascoders / react-native-image-viewer

🚀 tiny & fast lib for react native image viewer pan and zoom
MIT License
2.45k stars 580 forks source link

No Option to disable the index #425

Closed Dontag closed 4 years ago

Dontag commented 4 years ago

there is no option to disable the Index Indicator. It is important if need to show only one image

helsonxiao commented 4 years ago

Actually this can be done via prop renderIndicator.

Dontag commented 4 years ago

Actually this can be done via prop renderIndicator.

but how to do it??

mh7777777 commented 4 years ago

@Dontag

renderIndicator={() => {}}

Dontag commented 4 years ago

@Dontag

renderIndicator={() => {}}

Yes Got it,

kockok commented 3 years ago

@Dontag It would raise a typescript error simply by adding renderIndicator={() => {}}:

自定义计时器

No overload matches this call.
  Overload 1 of 2, '(props: Props | Readonly<Props>): ImageViewer', gave the following error.
    Type '() => void' is not assignable to type '(currentIndex?: number | undefined, allSize?: number | undefined) => ReactElement<any, string | JSXElementConstructor<any>>'.
      Type 'void' is not assignable to type 'ReactElement<any, string | JSXElementConstructor<any>>'.
  Overload 2 of 2, '(props: Props, context: any): ImageViewer', gave the following error.
    Type '() => void' is not assignable to type '(currentIndex?: number | undefined, allSize?: number | undefined) => ReactElement<any, string | JSXElementConstructor<any>>'.ts(2769)
image-viewer.type.d.ts(113, 5): The expected type comes from property 'renderIndicator' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<ImageViewer> & Pick<Readonly<Props> & Readonly<{ ...; }>, "children"> & Partial<...> & Partial<...>'
image-viewer.type.d.ts(113, 5): The expected type comes from property 'renderIndicator' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<ImageViewer> & Pick<Readonly<Props> & Readonly<{ ...; }>, "children"> & Partial<...> & Partial<...>'

Can you set an option to accept false as the value to disable the indicator?

MichaelDepp commented 3 years ago

@Dontag It would raise a typescript error simply by adding renderIndicator={() => {}}:

自定义计时器

No overload matches this call.
  Overload 1 of 2, '(props: Props | Readonly<Props>): ImageViewer', gave the following error.
    Type '() => void' is not assignable to type '(currentIndex?: number | undefined, allSize?: number | undefined) => ReactElement<any, string | JSXElementConstructor<any>>'.
      Type 'void' is not assignable to type 'ReactElement<any, string | JSXElementConstructor<any>>'.
  Overload 2 of 2, '(props: Props, context: any): ImageViewer', gave the following error.
    Type '() => void' is not assignable to type '(currentIndex?: number | undefined, allSize?: number | undefined) => ReactElement<any, string | JSXElementConstructor<any>>'.ts(2769)
image-viewer.type.d.ts(113, 5): The expected type comes from property 'renderIndicator' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<ImageViewer> & Pick<Readonly<Props> & Readonly<{ ...; }>, "children"> & Partial<...> & Partial<...>'
image-viewer.type.d.ts(113, 5): The expected type comes from property 'renderIndicator' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<ImageViewer> & Pick<Readonly<Props> & Readonly<{ ...; }>, "children"> & Partial<...> & Partial<...>'

Can you set an option to accept false as the value to disable the indicator?

try this renderIndicator={() => null}

kockok commented 3 years ago

nderIndicator={() => null}

not working...

kockok commented 3 years ago

returning an empty jsx would do the trick instead (tested only on ios): renderIndicator={() => (<></>)}

Dontag commented 3 years ago

returning an empty jsx would do the trick instead (tested only on ios): renderIndicator={() => (<></>)}

Yes working on iOS 👍