Kevin Powell - CommunityKP-C
Kevin Powell - Communityβ€’3y agoβ€’
91 replies
indee

is this called as prop drilling ?

// App.js
import { useState } from 'react';
import Rating from './components/Rating';
import Thankyou from './components/Thankyou';

function App() {
    const [selectedRating, setSelectedRating] = useState(0);
    const [showThankyou, setShowThankyou] = useState(false);

    const handleRatingChange = (rating) => {
        setSelectedRating(rating);
    };

    const handleRatingSubmit = () => {
        setShowThankyou(true);
    };

    return (
        <div className='font-outfit h-screen grid place-items-center'>
            {!showThankyou ? (
                <Rating onRatingChange={handleRatingChange} onRatingSubmit={handleRatingSubmit} />
            ) : (
                <Thankyou value={selectedRating} />
            )}
        </div>
    );
}

export default App;
Was this page helpful?