Inferencer
You can automatically generate views for your resources using @pankod/refine-inferencer
. Inferencer exports ChakraUIListInferencer
, ChakraUIShowInferencer
, ChakraUIEditInferencer
, ChakraUICreateInferencer
and ChakraUIInferencer
(which combines all in one place) components.
Usageβ
Chakra UI components can be imported from @pankod/refine-inferencer/chakra-ui
. You can directly use the components in resources
prop of Refine
component or you can use them in your custom components by passing the resource
prop as the resource name.
- In
resources
prop - In Custom Components
import { Layout, ChakraProvider, refineTheme } from "@pankod/refine-chakra-ui";
import { ChakraUIInferencer } from "@pankod/refine-inferencer/chakra-ui";
const App = () => {
return (
<ChakraProvider theme={refineTheme}>
<Refine
resources={[
{
name: "samples",
list: ChakraUIInferencer,
show: ChakraUIInferencer,
create: ChakraUIInferencer,
edit: ChakraUIInferencer,
},
]}
/>
</ChakraProvider>
);
};
import { ChakraUIInferencer } from "@pankod/refine-inferencer/chakra-ui";
const SampleList = () => {
return (
<ChakraUIInferencer resource="samples" action="list" />
);
};
const SampleShow = () => {
return (
<ChakraUIInferencer resource="samples" action="show" id="1" />
);
};
const SampleCreate = () => {
return (
<ChakraUIInferencer resource="samples" action="create" />
);
};
const SampleEdit = () => {
return (
<ChakraUIInferencer resource="samples" action="edit" id="1" />
);
};
To learn more about @pankod/refine-inferencer
package, please check out Docs
Viewsβ
List
β
Generates a sample list view for your resources according to the API response. It uses List
component from @pankod/refine-chakra-ui
and useTable
hook from @pankod/refine-react-table
.
Show
β
Generates a sample show view for your resources according to the API response. It uses Show
and field components from @pankod/refine-chakra-ui
with useShow
hook from @pankod/refine-core
.
Create
β
Generates a sample create view for your resources according to the first record in list API response. It uses Create
component from @pankod/refine-chakra-ui
and useForm
hook from @pankod/refine-react-hook-form
.
Edit
β
Generates a sample edit view for your resources according to the API response. It uses Edit
component from @pankod/refine-chakra-ui
and useForm
hook from @pankod/refine-react-hook-form
.
Exampleβ
Below you'll find a Live CodeSandbox Example displaying a fully setup Refine
app with @pankod/refine-inferencer/chakra-ui
components.
npm create refine-app@latest -- --example inferencer-chakra-ui