Simply change the useState([YOUR_HARDCODE_VALUE]);. Example shown below
const [apiResponseValue, setApiResponseValue] = useState(0);
Below is the full code:
import OtpListing from '../propertysearch/OtpListing';
// State to hold the API response value
const [apiResponseValue, setApiResponseValue] = useState(0); // Hardcoded value of 0
// Simulate API call using useEffect
useEffect(() => {
// Simulated API call
const fetchData = async () => {
try {
// Simulated API response
const response = await fetch('your-api-endpoint');
const data = await response.json();
// Set the API response value to the state
setApiResponseValue(data.value); // Assuming your API response has a key 'value'
} catch (error) {
console.error('Error fetching API:', error);
}
};
// Call the fetchData function
fetchData();
}, []); // Empty dependency array to execute only once on component mount
return (
<>
{apiResponseValue === 0 && <OtpListing />}
</>
);
}