Comments (8)
I'm closing this issue because it is fixed in the major version update 2.0.0
@smirea just notice I also changed the API.
from react-inline-transition-group.
Hi @smirea. Is this happening with the version 1.1.0?
from react-inline-transition-group.
yep. it seems react is lazyly replacing the DOM element for subcomponents - which happens before you setAttribute in the 2nd example, and after you setAttribute in the first example
from react-inline-transition-group.
Can you tell me your React version? I tested your code here and worked as expected
from react-inline-transition-group.
"react": "^15.3.2",
"react-dom": "^15.3.2",
"react-inline-transition-group": "^1.1.0",
from react-inline-transition-group.
It is the same as me. I'm not being able to reproduce. Can you, please, submit your code somewhere?
from react-inline-transition-group.
Ok i figured out how to cause the issue. It only happens if a parent component updates on mount (e.g. setState in componentWillMount). The initial state will be invalid but the second the parent updates everything is fixed.
Here is the full code:
import React, {Component} from 'react';
import Transition from 'react-inline-transition-group';
export default class App extends Component {
state = {};
handleRef = elem => {
this.setState({rand: Math.random()})
}
render () {
return (
<div ref={this.handleRef}>
<TransitionTest />
</div>
);
}
}
class TransitionTest extends Component {
state = {
list: '1234567890'.split(''),
};
render () {
const {list} = this.state;
const TestClass = (props) => <div {...props} />
return (
<div>
<div onClick={() => this.setState({list: [Math.random()].concat(list)}) }> ++ add ++ </div>
<Transition
childrenBaseStyle={{
background: 'red',
}}
>
{list.map((val, index) => {
const props = {
key: val,
onClick: () => this.setState({list: list.filter(v => v !== val)}),
};
return index % 2 === 0 ?
<TestClass {...props}>{val}</TestClass> :
<div {...props}>{val}</div>
})}
</Transition>
</div>);
}
}
You should see half the rows red and half white. if you add/remove anything the state becomes valid.
If you remove the setState()
from handleRef()
the state is also initialized valid
from react-inline-transition-group.
I believe the problem starts with the stateless component you are using.
When I apply the styles I do it manually using the setAttribute()
. React stateless components are optimized in some ways that I'm not aware of, but they probably are caching the component definition since it is just a function. And in your definition const TestClass = (props) => <div {...props} />
the styles are not yet present
I found a way to fix this, but I need to be sure of the side effects. In the meantime you can avoid using stateless components.
from react-inline-transition-group.
Related Issues (10)
- Can't fade in Route(s) with react-inline-transition-group ( React-Router ) HOT 5
- Cannot change previous child's transition styles HOT 1
- Add TypeScript typings HOT 1
- doesn't work with prefix. HOT 4
- React Style unit inference does not work anymore HOT 2
- Children don't update their base styles HOT 8
- Component element causing layout issues HOT 2
- How to use with react-router? HOT 10
- Change styling for transitioning components HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-inline-transition-group.