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.

Conditional Rendering inside Form

See original GitHub issue

I have scenario where i have Form with coditional FormGroups inside like that:

const [isEdit] = useState(false);

And Component return looks more than less like that:

return 
<Form>
  <FormGroup/>
  {isEdit && <FormGroup/>}
  <FormGroup/>
</Form>

Error from compiler is:

image

TS2322

Please adjust Childern type for Form also to be false | React.ReactElement

Today workarround for this would be:

return 
<Form>
  <FormGroup/>
  {(isEdit && <FormGroup/>) as ReactElement}
  <FormGroup/>
</Form>

Plase change: https://github.com/SAP/ui5-webcomponents-react/blob/0d303095e84fa23f1bdd1467aa9141d7c67088c1/packages/main/src/components/Form/index.tsx#L26

to:

children: false | ReactElement | ReactElement[];

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
nazarkulykcommented, Aug 12, 2022

@Lukas742 Please, same for FormGroup. Currently i get even error with workarround FromGroup where we have ReactNode. It tries to render “false”…

0reactions
ui5-webcomponents-react-botcommented, Aug 26, 2022

🎉 This issue has been resolved in version v0.27.4 🎉

The release is available on v0.27.4

Your semantic-release bot 📦🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

Conditional form rendering in react - Stack Overflow
Conditional form rendering in react · Which is your select box component that you want to show on based of this. · x01...
Read more >
Conditional Rendering - React
Conditional rendering in React works the same way conditions work in JavaScript. Use JavaScript operators like if or the conditional operator to create...
Read more >
Six methods to achieve conditional rendering in React - Flexiple
In this article, we'll be discussing conditional rendering in ReactJS and looking at different ways to handle those cases.
Read more >
7 Ways to Implement Conditional Rendering in React ...
Conditional rendering is a term to describe the ability to render different user interface (UI) markup if a condition is true or false....
Read more >
How do you do conditional rendering in React?
Conditional rendering is about displaying style or HTML depending on your React state. In other words, we are adding logic and conditionals ...
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