question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Request] More flexibility of Component props

See original GitHub issue

As requested in #776 by @artyorsh:

Issue type

I’m submitting a …

  • feature request

Issue description

Current behavior: Attempting to customize the contents of a Components to compose new, exciting components is impossible. Trying to achieve something like this:

const ImpossibleTopNavigation = (props) => (
   <TopNavigation {...props} title={<Image {... someStuff} />} />
);

Ends up with this error: Type 'Element' is not assignable to type 'string' (Because title only allows strings)

Expected behavior: Most Components in UI Kitten with small modifications can receive a different PropType and still function properly… avoiding awkward workarounds:

const PossibleNavigation = (props) => (
   <TopNavigation {...props} title={<Image {... someStuff} />} />
);

const LoadingButton: ({ isLoading, children }) => {
  <Button>
     {/* This doesn't cover disabling it an other stuff, but you get the idea */}
     {isLoading ? (<SomeCoolSpinner />) : (children)}
  </Button>
};

By allowing for more flexibility in contents of components like Text or Button, probably these kinds of issues probably won’t exist anymore:

I believe that would require repeating #627 on the rest of Components’ Props interfaces/types. I did something similar for my particular need of customizing the TopNavigationBarComponent.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8

github_iconTop GitHub Comments

1reaction
lesmocommented, Apr 8, 2020

@lesmo I’m happy to say this is available in v5 😃 Release notes

Lovely!! Thanks!! Migration looks pretty straightforward, maybe I’ll update my production App. I’ll upgrade my current project to use v5.

I guess I’ll close this issue 😄

1reaction
artyorshcommented, Apr 8, 2020

@lesmo I’m happy to say this is available in v5 😃 Release notes

Read more comments on GitHub >

github_iconTop Results From Across the Web

Components and Props - React
Components let you split the UI into independent, reusable pieces, and think about each piece in isolation. This page provides an introduction to...
Read more >
[feature request] Pass custom controls components as props ...
In order to provide more flexibility we may consider have a way passing custom controls components to moveable (we can omit this feature...
Read more >
How To Customize React Components with Props
In this tutorial, you'll create custom components by passing props to your component. Props are arguments that you provide to a JSX element....
Read more >
A Simple Guide to Component Props in React
Let's make the <HelloWorld /> component more flexible by adding a prop who . The who allows to custimize the person that's being...
Read more >
Defining Props in React Function Component with Typescript
This allows more flexibility in how you can define your props. 1// Using the same FullName interface from the last example 2function ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found