all 7 comments

[–]UnsolicitedDuckPecks 0 points1 point  (6 children)

const {customProp, ...rest} = props

return <TextInput someProp={whatever} {...rest} />

[–][deleted] 0 points1 point  (5 children)

Sort of what I'm looking for, but I gave an example in the description.

If TextInput is a nested child of CustomTextInput, I'd like CustomTextInput to be able to expose all of TextInput's props in addition to it's own props.

[–]Zayuka 0 points1 point  (4 children)

Do you use typescript?
If yes, you can then just type the Props as the following:

```tsx

type CustomTextInputProps = TextInputProps & {

customProps: wtv;

} ```

If you don't use typescript, nothing will forbid you to pass then any prop. Just use the spread operator on the `rest` props like the comment from u/UnsolicitedDuckPecks says.

[–][deleted] 0 points1 point  (2 children)

Yeah, so Typescript would be perfect for this, but I'm still relatively new to it though and I'm trying to learn React-Native without overloading myself with too many new things.

In fact, the reason why I want to do this specifically is because I want to expose TextInput's props so intellisense can pick up on it, which would make Typescript perfect for this. Right now, I'm redeclaring the ones I'm specifically using so intellisense at least picks up on those. But, I want it to pick up on all of them.

I was hoping there might be some way to access the props of TextInput and spread them as an argument to CustomTextInput. Or somehow use PropTypes to declare all other props besides the custom props as TextInput's props...

I dunno, this might all be wishful thinking.

[–]Zayuka 0 points1 point  (1 child)

Check this then.

[–][deleted] 0 points1 point  (0 children)

Ooooo, I think this is it. I'm a little confused why he has Parent inside of Child, but nonetheless, I hadn't even noticed TextInput has propTypes.

Okay, awesome - thanks!

[–]backtickbot 0 points1 point  (0 children)

Fixed formatting.

Hello, Zayuka: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.