conditional-rendering

How to fetch data in React/Redux from mongoose/mongodb using router to reflect changes in state of component?

孤人 提交于 2020-06-17 09:08:10
问题 Trying to render a component only the first time user logs into my MERN app to show a questionnaire, otherwise user is taken to the dashboard. I am able to manipulate redux state to show firstLogin as changing in my auth reducer by using an action that sets firstlogin to true (independent of the FirstLogin value changed in my database) after the user fills the questionnaire and even update the value of FirstLogin in the User's collection in my mongodb. I am sharing my authActions authReducer

React Native: Can you conditionally render JSX based on the existence of a string?

旧时模样 提交于 2020-05-17 07:42:45
问题 In my React Native app, I'm trying to conditionally render a <Text> component based on whether or not a particular string exists. I tried to do it this way: <View> { someString && <Text> {someString} </Text> } </View> This threw the error Text strings must be rendered within a <Text> component . I did it this way and it worked fine. <View> { someString ? <Text> {someString} </Text> : null } </View> I assume the problem is that with the first method, it's trying to actually render the string,

React JS: How to animate conditionally rendered components?

ε祈祈猫儿з 提交于 2020-05-15 08:05:12
问题 Example is a functional component in which I am rendering a div conditionally. I want this div to fade-in when rendered conditionally and fade-out vice versa. For that, I have maintained two local state variables: render and fadeIn which are computed based on show prop passed down to the Example component. What I've done is: When show prop it true , I set render as true , so the div renders conditionally and after a timeout of 10ms I set fadeIn as true which will set CSS classname for my div

How to build “edit” button in JSF and switch between h:outputText and h:inputText

回眸只為那壹抹淺笑 提交于 2019-12-29 06:34:13
问题 How can I create an "edit" button so that when the button is clicked it will change the h:outputText to h:inputText ? 回答1: Make use of the rendered attribute: <h:outputText value="#{bean.entity.property}" rendered="#{not bean.editmode}" /> <h:inputText value="#{bean.entity.property}" rendered="#{bean.editmode}" /> ... <h:commandButton value="Edit" action="#{bean.edit}" rendered="#{not bean.editmode}" /> <h:commandButton value="Save" action="#{bean.save}" rendered="#{bean.editmode}" /> With

How to build “edit” button in JSF and switch between h:outputText and h:inputText

南笙酒味 提交于 2019-12-29 06:33:14
问题 How can I create an "edit" button so that when the button is clicked it will change the h:outputText to h:inputText ? 回答1: Make use of the rendered attribute: <h:outputText value="#{bean.entity.property}" rendered="#{not bean.editmode}" /> <h:inputText value="#{bean.entity.property}" rendered="#{bean.editmode}" /> ... <h:commandButton value="Edit" action="#{bean.edit}" rendered="#{not bean.editmode}" /> <h:commandButton value="Save" action="#{bean.save}" rendered="#{bean.editmode}" /> With

Dynamic TabView primefaces, tab rendered attribute doesn't work

戏子无情 提交于 2019-12-25 06:39:20
问题 i have a "problem" with a tab component for tabView from Primefaces. I did a tabView with dynamic tabs based on a array. But some tabs can't be rendered, based on a boolean attribute of the object from that array . I tried rendered="true" or "false" but nothing happens (on tab). I use rendered="#{_item.show}" i tried use disabled feature and works fine, but is not my need. Someone have an idea to how to solve this issue? check my code: <p:tabView id="tabs" value="#{myBean.list}" var="_item"

Conditionally render components with ajax conditionally only if validation passes

荒凉一梦 提交于 2019-12-24 02:48:15
问题 I am using JSF 2.2 and I was wondering if there is a way to render components with ajax conditionally only if the validation passes. By using the render attribute of ajax the components will be rendered regardless of the validation passing or not. What I'm after is something like: <f:ajax ... render="#{validationHasPassed ? 'foo' : ''}" /> ... <h:panelGroup id="foo"> <!-- other components here --> </h:panelGroup> Is it possible to conditionally render a component in a similar way like this?

Value expressions still evaluated despite ui:fragment rendered=“false”

◇◆丶佛笑我妖孽 提交于 2019-12-20 07:35:06
问题 I have bean: class Property{ private String type; private Date value; //getters and setters } also have block of code on page: <ui:fragment rendered="#{property.type eq 'checkbox'}"> <ui:include src="checkbox.xhtml"> <ui:param name="property" value="#{property}"/> </ui:include> </ui:fragment> checkbox.xhtml: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java

Conditionally render JSF components for printing

╄→尐↘猪︶ㄣ 提交于 2019-12-17 20:29:23
问题 I want to print only a certain part of my webpage (so not the whole page). How can I achieve this in JSF? 回答1: This is normally to be controlled by CSS with display: none|block . Check the CSS media rules. For example, as @media print {} inside a default CSS file: @media print { #header, #footer, #menu { display: none; } } (the above example will hide HTML elements with IDs header , footer and menu ) Or via a generic style class: @media screen { .printonly { display: none; } } @media print {

Image flickering issue in React when image is conditionally rendered

余生长醉 提交于 2019-12-12 04:29:23
问题 I have a header and I want to show an image on its right when the mouse is over the header. I am maintaining a variable editMode in the state which is set to true/false Then I am conditionally rendering the image using onMouseOver and onMouse events. Now when I hover over the header, the edit mode is set to true and the image shows up and when I move the cursor out of the header, the editMode sets to false and the image disappears. I am maintaining a variable editMode in the state which is