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










1















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;










share|improve this question
























  • 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















1















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;










share|improve this question
























  • 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













1












1








1








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;










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 had in= 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











  • 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
















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












1 Answer
1






active

oldest

votes


















1














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>





share|improve this answer






















    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
    );



    );













    draft saved

    draft discarded


















    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









    1














    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>





    share|improve this answer



























      1














      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>





      share|improve this answer

























        1












        1








        1







        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>





        share|improve this answer













        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>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 7 at 8:50









        Danielle LCDanielle LC

        813




        813





























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

            Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

            Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved