react-transition-group CSSTransition, conditional with null2019 Community Moderator ElectionTransitions on the display: propertyHow can I transition height: 0; to height: auto; using CSS?Loop inside React JSXProgrammatically navigate using react routerHow get value datapicker in react toobox custom?React-redux tutorial : Where does children come fromTransitionGroup and CssTransition: Exit transition not appliedReact CSSTransition wrong class used on exitRedux - mapDispatchToProps - TypeError: _this.props.setCurrentUserHandle is not a functionCSSTransition from react-transition-group does not exit
Current sense amp + op-amp buffer + ADC: Measuring down to 0 with single supply
Do I need life insurance if I can cover my own funeral costs?
What is IP squat space
Does this AnyDice function accurately calculate the number of ogres you make unconcious with three 4th-level castings of Sleep?
What is this large pipe coming out of my roof?
How can I change step-down my variable input voltage? [Microcontroller]
Be in awe of my brilliance!
Why are the outputs of printf and std::cout different
Calculus II Professor will not accept my correct integral evaluation that uses a different method, should I bring this up further?
Could the Saturn V actually have launched astronauts around Venus?
2D counterpart of std::array in C++17
What options are left, if Britain cannot decide?
Is it possible to upcast ritual spells?
Use of プラトニック in this sentence?
Good allowance savings plan?
Official degrees of earth’s rotation per day
What are the possible solutions of the given equation?
What are some nice/clever ways to introduce the tonic's dominant seventh chord?
Identifying the interval from A♭ to D♯
Have researchers managed to "reverse time"? If so, what does that mean for physics?
How to deal with taxi scam when on vacation?
Why do passenger jet manufacturers design their planes with stall prevention systems?
How to answer questions about my characters?
Welcoming 2019 Pi day: How to draw the letter π?
react-transition-group CSSTransition, conditional with null
2019 Community Moderator ElectionTransitions on the display: propertyHow can I transition height: 0; to height: auto; using CSS?Loop inside React JSXProgrammatically navigate using react routerHow get value datapicker in react toobox custom?React-redux tutorial : Where does children come fromTransitionGroup and CssTransition: Exit transition not appliedReact CSSTransition wrong class used on exitRedux - mapDispatchToProps - TypeError: _this.props.setCurrentUserHandle is not a functionCSSTransition from react-transition-group does not exit
Trying to get a simple fade in/out transition working.
I've tried moving the <CSSTransition>
around into different areas to no avail. I'm using this successfully in another component that's mapping children but can't see why it wouldn't work in this case since I'm rendering it together with the child component, if the child gets returned at all.
Child component
const Error = (props) =>
return (
<CSSTransition timeout=400 classNames=errorTransition>
<span> props.errorString </span>
</CSSTransition>
)
Parent component
import React, Component from 'react';
import connect from 'react-redux';
import CSSTransition from 'react-transition-group';
import type InfoState from './state';
import closeError from './actions';
const mapStateToProps = (state: info: InfoState) => (
info: state.info.data.info,
infoError: state.info.infoError,
);
const mapDispatchToProps = dispatch => (
closeError: () => dispatch(closeError()),
);
class Parent extends Component<Props, State>
state = info: this.props.info ;
handleChange = (e) =>
this.setState( info: e.target.value );
this.props.closeError();
render()
if (this.props.info === null)
return (
<div className="info-wrapper">
<input
type="text"
value=this.state.info ? this.state.info : ''
onChange=this.handleChange
/>
</div>
<div className="info-error">
this.props.infoError !== ''
? <Error
key=this.state.info
errorString=this.props.infoError
/>
: null
</div>
)
return ( <div> things </div> )
CSS
.errorTransition-enter
opacity: 0.01;
.errorTransition-enter-active
opacity: 1;
transition: all 400ms ease-out;
.errorTransition-exit
opacity: 1;
.errorTransition-exit-active
opacity: 0.01;
transition: all 400ms ease-out;
reactjs css-transitions react-transition-group
|
show 1 more comment
Trying to get a simple fade in/out transition working.
I've tried moving the <CSSTransition>
around into different areas to no avail. I'm using this successfully in another component that's mapping children but can't see why it wouldn't work in this case since I'm rendering it together with the child component, if the child gets returned at all.
Child component
const Error = (props) =>
return (
<CSSTransition timeout=400 classNames=errorTransition>
<span> props.errorString </span>
</CSSTransition>
)
Parent component
import React, Component from 'react';
import connect from 'react-redux';
import CSSTransition from 'react-transition-group';
import type InfoState from './state';
import closeError from './actions';
const mapStateToProps = (state: info: InfoState) => (
info: state.info.data.info,
infoError: state.info.infoError,
);
const mapDispatchToProps = dispatch => (
closeError: () => dispatch(closeError()),
);
class Parent extends Component<Props, State>
state = info: this.props.info ;
handleChange = (e) =>
this.setState( info: e.target.value );
this.props.closeError();
render()
if (this.props.info === null)
return (
<div className="info-wrapper">
<input
type="text"
value=this.state.info ? this.state.info : ''
onChange=this.handleChange
/>
</div>
<div className="info-error">
this.props.infoError !== ''
? <Error
key=this.state.info
errorString=this.props.infoError
/>
: null
</div>
)
return ( <div> things </div> )
CSS
.errorTransition-enter
opacity: 0.01;
.errorTransition-enter-active
opacity: 1;
transition: all 400ms ease-out;
.errorTransition-exit
opacity: 1;
.errorTransition-exit-active
opacity: 0.01;
transition: all 400ms ease-out;
reactjs css-transitions react-transition-group
Can you share everything inside the components? Thanks.
– Javier Molinas Vilas
Mar 6 at 18:45
Are you sure that this condition:this.props.infoError !== ' '
returns true?
– ladyk
Mar 6 at 18:48
@ladyk yep! I'm catching the error every time correctly
– raccoon_nine
Mar 6 at 19:07
so I think the case is you're not passing 'in' parameter in CSSTransition, please look at the example: reactcommunity.org/react-transition-group/css-transition/…
– ladyk
Mar 6 at 19:21
@ladyk I tried that as well so I hadin= props.errorString !== ''
but no transition still
– raccoon_nine
Mar 6 at 19:27
|
show 1 more comment
Trying to get a simple fade in/out transition working.
I've tried moving the <CSSTransition>
around into different areas to no avail. I'm using this successfully in another component that's mapping children but can't see why it wouldn't work in this case since I'm rendering it together with the child component, if the child gets returned at all.
Child component
const Error = (props) =>
return (
<CSSTransition timeout=400 classNames=errorTransition>
<span> props.errorString </span>
</CSSTransition>
)
Parent component
import React, Component from 'react';
import connect from 'react-redux';
import CSSTransition from 'react-transition-group';
import type InfoState from './state';
import closeError from './actions';
const mapStateToProps = (state: info: InfoState) => (
info: state.info.data.info,
infoError: state.info.infoError,
);
const mapDispatchToProps = dispatch => (
closeError: () => dispatch(closeError()),
);
class Parent extends Component<Props, State>
state = info: this.props.info ;
handleChange = (e) =>
this.setState( info: e.target.value );
this.props.closeError();
render()
if (this.props.info === null)
return (
<div className="info-wrapper">
<input
type="text"
value=this.state.info ? this.state.info : ''
onChange=this.handleChange
/>
</div>
<div className="info-error">
this.props.infoError !== ''
? <Error
key=this.state.info
errorString=this.props.infoError
/>
: null
</div>
)
return ( <div> things </div> )
CSS
.errorTransition-enter
opacity: 0.01;
.errorTransition-enter-active
opacity: 1;
transition: all 400ms ease-out;
.errorTransition-exit
opacity: 1;
.errorTransition-exit-active
opacity: 0.01;
transition: all 400ms ease-out;
reactjs css-transitions react-transition-group
Trying to get a simple fade in/out transition working.
I've tried moving the <CSSTransition>
around into different areas to no avail. I'm using this successfully in another component that's mapping children but can't see why it wouldn't work in this case since I'm rendering it together with the child component, if the child gets returned at all.
Child component
const Error = (props) =>
return (
<CSSTransition timeout=400 classNames=errorTransition>
<span> props.errorString </span>
</CSSTransition>
)
Parent component
import React, Component from 'react';
import connect from 'react-redux';
import CSSTransition from 'react-transition-group';
import type InfoState from './state';
import closeError from './actions';
const mapStateToProps = (state: info: InfoState) => (
info: state.info.data.info,
infoError: state.info.infoError,
);
const mapDispatchToProps = dispatch => (
closeError: () => dispatch(closeError()),
);
class Parent extends Component<Props, State>
state = info: this.props.info ;
handleChange = (e) =>
this.setState( info: e.target.value );
this.props.closeError();
render()
if (this.props.info === null)
return (
<div className="info-wrapper">
<input
type="text"
value=this.state.info ? this.state.info : ''
onChange=this.handleChange
/>
</div>
<div className="info-error">
this.props.infoError !== ''
? <Error
key=this.state.info
errorString=this.props.infoError
/>
: null
</div>
)
return ( <div> things </div> )
CSS
.errorTransition-enter
opacity: 0.01;
.errorTransition-enter-active
opacity: 1;
transition: all 400ms ease-out;
.errorTransition-exit
opacity: 1;
.errorTransition-exit-active
opacity: 0.01;
transition: all 400ms ease-out;
reactjs css-transitions react-transition-group
reactjs css-transitions react-transition-group
edited Mar 6 at 19:11
raccoon_nine
asked Mar 6 at 18:16
raccoon_nineraccoon_nine
93
93
Can you share everything inside the components? Thanks.
– Javier Molinas Vilas
Mar 6 at 18:45
Are you sure that this condition:this.props.infoError !== ' '
returns true?
– ladyk
Mar 6 at 18:48
@ladyk yep! I'm catching the error every time correctly
– raccoon_nine
Mar 6 at 19:07
so I think the case is you're not passing 'in' parameter in CSSTransition, please look at the example: reactcommunity.org/react-transition-group/css-transition/…
– ladyk
Mar 6 at 19:21
@ladyk I tried that as well so I hadin= props.errorString !== ''
but no transition still
– raccoon_nine
Mar 6 at 19:27
|
show 1 more comment
Can you share everything inside the components? Thanks.
– Javier Molinas Vilas
Mar 6 at 18:45
Are you sure that this condition:this.props.infoError !== ' '
returns true?
– ladyk
Mar 6 at 18:48
@ladyk yep! I'm catching the error every time correctly
– raccoon_nine
Mar 6 at 19:07
so I think the case is you're not passing 'in' parameter in CSSTransition, please look at the example: reactcommunity.org/react-transition-group/css-transition/…
– ladyk
Mar 6 at 19:21
@ladyk I tried that as well so I hadin= props.errorString !== ''
but no transition still
– raccoon_nine
Mar 6 at 19:27
Can you share everything inside the components? Thanks.
– Javier Molinas Vilas
Mar 6 at 18:45
Can you share everything inside the components? Thanks.
– Javier Molinas Vilas
Mar 6 at 18:45
Are you sure that this condition:
this.props.infoError !== ' '
returns true?– ladyk
Mar 6 at 18:48
Are you sure that this condition:
this.props.infoError !== ' '
returns true?– ladyk
Mar 6 at 18:48
@ladyk yep! I'm catching the error every time correctly
– raccoon_nine
Mar 6 at 19:07
@ladyk yep! I'm catching the error every time correctly
– raccoon_nine
Mar 6 at 19:07
so I think the case is you're not passing 'in' parameter in CSSTransition, please look at the example: reactcommunity.org/react-transition-group/css-transition/…
– ladyk
Mar 6 at 19:21
so I think the case is you're not passing 'in' parameter in CSSTransition, please look at the example: reactcommunity.org/react-transition-group/css-transition/…
– ladyk
Mar 6 at 19:21
@ladyk I tried that as well so I had
in= props.errorString !== ''
but no transition still– raccoon_nine
Mar 6 at 19:27
@ladyk I tried that as well so I had
in= props.errorString !== ''
but no transition still– raccoon_nine
Mar 6 at 19:27
|
show 1 more comment
1 Answer
1
active
oldest
votes
I was having a similar issue with conditionally removing an element wrapped with <CSSTransition>
. To solve the problem I wrapped the <CSSTransition>
element with a <TransitionGroup>
element and used its childFactory prop. The childFactory
prop can be used like so:
<TransitionGroup
childFactory=child => React.cloneElement(child)
>
<CSSTransition timeout=400 classNames=errorTransition>
<span> props.errorString </span>
</CSSTransition>
</TransitionGroup>
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55029740%2freact-transition-group-csstransition-conditional-with-null%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I was having a similar issue with conditionally removing an element wrapped with <CSSTransition>
. To solve the problem I wrapped the <CSSTransition>
element with a <TransitionGroup>
element and used its childFactory prop. The childFactory
prop can be used like so:
<TransitionGroup
childFactory=child => React.cloneElement(child)
>
<CSSTransition timeout=400 classNames=errorTransition>
<span> props.errorString </span>
</CSSTransition>
</TransitionGroup>
add a comment |
I was having a similar issue with conditionally removing an element wrapped with <CSSTransition>
. To solve the problem I wrapped the <CSSTransition>
element with a <TransitionGroup>
element and used its childFactory prop. The childFactory
prop can be used like so:
<TransitionGroup
childFactory=child => React.cloneElement(child)
>
<CSSTransition timeout=400 classNames=errorTransition>
<span> props.errorString </span>
</CSSTransition>
</TransitionGroup>
add a comment |
I was having a similar issue with conditionally removing an element wrapped with <CSSTransition>
. To solve the problem I wrapped the <CSSTransition>
element with a <TransitionGroup>
element and used its childFactory prop. The childFactory
prop can be used like so:
<TransitionGroup
childFactory=child => React.cloneElement(child)
>
<CSSTransition timeout=400 classNames=errorTransition>
<span> props.errorString </span>
</CSSTransition>
</TransitionGroup>
I was having a similar issue with conditionally removing an element wrapped with <CSSTransition>
. To solve the problem I wrapped the <CSSTransition>
element with a <TransitionGroup>
element and used its childFactory prop. The childFactory
prop can be used like so:
<TransitionGroup
childFactory=child => React.cloneElement(child)
>
<CSSTransition timeout=400 classNames=errorTransition>
<span> props.errorString </span>
</CSSTransition>
</TransitionGroup>
answered Mar 7 at 8:50
Danielle LCDanielle LC
813
813
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55029740%2freact-transition-group-csstransition-conditional-with-null%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you share everything inside the components? Thanks.
– Javier Molinas Vilas
Mar 6 at 18:45
Are you sure that this condition:
this.props.infoError !== ' '
returns true?– ladyk
Mar 6 at 18:48
@ladyk yep! I'm catching the error every time correctly
– raccoon_nine
Mar 6 at 19:07
so I think the case is you're not passing 'in' parameter in CSSTransition, please look at the example: reactcommunity.org/react-transition-group/css-transition/…
– ladyk
Mar 6 at 19:21
@ladyk I tried that as well so I had
in= props.errorString !== ''
but no transition still– raccoon_nine
Mar 6 at 19:27