react-ref

React native ref Property 'ref' does not exist on type 'IntrinsicAttributes &

限于喜欢 提交于 2021-01-29 12:49:01
问题 I am getting the following error but I am not able to figure out how to fix it someone can help me out. Below is also the link on expo with the complete code. Error on <AppIntroSlider /> which is reported by snack expo Example: Type '{ ref: (ref: any) => any; data: { key: string; title: string; text: string; backgroundColor: string; }[]; renderItem: ({ item }: any) => Element; renderPagination: (activeIndex: number) => Element; scrollX: (scrollXList: any) => any; }' is not assignable to type

React/Typescript forwardRef types for an element which returns either an input or textArea

三世轮回 提交于 2021-01-27 04:12:19
问题 I'm trying to create a generic text input component for our application using react and typescript. I want it to be able to either be an input element or a textarea element based on a given prop. So it looks somewhat like this: import {TextArea, Input} from 'ourComponentLibrary' export const Component = forwardRef((props, ref) => { const Element = props.type === 'textArea' ? TextArea : Input return ( <Element ref={ref} /> ) }) This code works fine. However, when trying to incorporate types it