Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to change cards dynamically using react #26

Open
eight-bitguy opened this issue Jun 2, 2020 · 0 comments
Open

Not able to change cards dynamically using react #26

eight-bitguy opened this issue Jun 2, 2020 · 0 comments

Comments

@eight-bitguy
Copy link

export default class GamePage extends Page {
    constructor(props) {
        super(props);
        this.state = {
            cards: ['2D', '4D']
        };
    }

    async componentDidMount() {
        setTimeout(this.addCards, 1000);
    };

    addCards = () => this.setState({
        cards: ['2D', '4D', '2D', '4D']
    });

    render() {
        const cardsToRender = this.state.cards;

        return (
            <div className='row'>
                <div className="m-5 hand active-hand fan" data-fan={`spacing: 0.2; width: 180; radius: 850;`}>
                    {cardsToRender.map(card => <img className='card' src={`./Images/${card}.svg`} alt='hello'/>)}
                </div>
            </div>
        );
    }
}

For time 0 to 1 cards are rendered perfectly. But for time > 1, all cards just overlaps on each other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant