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

Doesn't work start props of Counter component in React Native #17

Open
minhphuongvong07 opened this issue Feb 28, 2024 · 2 comments
Open

Comments

@minhphuongvong07
Copy link

const [coffeeCount,setCoffeCount] = useState(0);
<Counter
start={coffeeCount}
onChange={(newCount) => {
console.log(coffeeCount.toString);
console.log(newCount);
setCoffeeCount(newCount);
setInteractionMade(true);
}}
buttonStyle={styles.counterButton}
buttonTextStyle={styles.counterButtonText}
countTextStyle={styles.counterText}
/>

            coffeeCount is state of Component.
            Stat props doesn't work, but start={3} works
@minhphuongvong07
Copy link
Author

componentDidUpdate(prevProps) {
if (prevProps.start !== this.props.start) {
this.setState({ count: this.props.start });
}
}

Please add this part and then fixed

@minhphuongvong07
Copy link
Author

minhphuongvong07 commented Feb 28, 2024

If you satisfy, I hope you to hep my job seeking
[email protected]

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