- with just a ready state, using an anonymous function.
<QueryRenderer query={query}>
{(data) => (
<p>{data.hello}</p>
)}
</QueryRenderer>
- with just a ready state, using a component.
const QueryComponent: React.FC<QueryData> = (data) => (
<p>{data.hello}</p>
);
<QueryRenderer query={query}>
{QueryComponent}
</QueryRenderer>
- overriding custom rendering states, using anonymous functions or components.
with this interface, all states besides
REQUIRED
are optional.
(don't worry, the compiler will remind you.)
see QueryRendererState
for all options.
<QueryRenderer query={query}>
{{
[QueryRendererState.EXPECTED_ERROR]: ({ error }) => <p>Custom Error: {error.message}.</p>,
[QueryRendererState.READY]: QueryComponent,
}}
</QueryRenderer>