I don't think you can render a component in an axios interceptor.
The interceptor will intercept every response you make, and if there is an error do something with the error.
Meaning React would have no way of knowing what to render in which part of the DOM based on an error on any response from axios. Here is a good explanation of how interceptors work and good use cases for them
If you want to render an error message to the user then don't intercept the response. Just wait until the response errors (in a normal request not an interceptor) then pass that error to your own error component.
In practice that might look something like the below
function apiQuery (url) {
const [error, setError] = useState(null);
const [api, setApi] = useState(null);
axios.get(url)
.then(function (response) {
// handle success
setApi(response.data)
})
.catch(function (error) {
// handle error
setError(error)
})
return { api, error }
}
Now you have access to the error response which you can pass into your own error component
const api = apiQuery('/users')
// pass error into your bespoke component
if (api.error) return <Error error={error}/>