johnwards
johnwards
Explore posts from servers
CDCloudflare Developers
Created by johnwards on 11/6/2023 in #workers-help
PDF to image conversion
Hey, I'm really struggling to get PDF to image conversion working in a worker. Even with node compat on, I just keep hitting errors, which I guess is due to node compat not being 100%. Anyone got an idea about the best way to do PDF to image conversion at the worker level? (Use case is thumbnail preview for a PDF uploaded, I've got the PDF uploaded to a bucket). Thanks John
1 replies
RRefine
Created by foreign-sapphire on 4/5/2023 in #ask-any-question
Error: A component is changing an uncontrolled input to be controlled.
Using MuiInferencer on an api that has a boolean field (isActive) it generates the following code:
<Controller
control={control}
name="isActive"
// eslint-disable-next-line
defaultValue={null as any}
render={({ field }) => (
<FormControlLabel
label="Is Active"
control={
<Checkbox
{...field}
checked={field.value}
onChange={(event) => {
field.onChange(event.target.checked);
}}
/>
}
/>
)}
/>
<Controller
control={control}
name="isActive"
// eslint-disable-next-line
defaultValue={null as any}
render={({ field }) => (
<FormControlLabel
label="Is Active"
control={
<Checkbox
{...field}
checked={field.value}
onChange={(event) => {
field.onChange(event.target.checked);
}}
/>
}
/>
)}
/>
The problem is that in the console I get the following error: Warning: A component is changing an uncontrolled input to be controlled. This is likely caused by the value changing from undefined to a defined value, which should not happen. Decide between using a controlled or uncontrolled input element for the lifetime of the component. Are we safe to ignore this error? I don't understand enough about React and what you've generated to make a sensible decision, but I don't like my console littered with errors.
9 replies
RRefine
Created by jolly-crimson on 4/3/2023 in #ask-any-question
onSettled error when creating a child item
Hey, so we've overriden the save on click handler with our own function to create an "item", then once that "item" is created, we the create an "artwork" that belongs to that item. We capture all the details in one form. How we've done it is like this:
const { mutate } = useCreate();
const onSave = () => {
mutate({
resource: "item",
values: {
...itemValues,
},
},
{
onSuccess: (data) => {
const id = data.data.id;
const formData = new FormData();
formData.append('file', artworks[0]);

Object.keys(artworkValues).forEach((k, i) => {
var d = Object.values(artworkValues)[i];
formData.append(k, d);
})

mutate({
resource: `item/${id}/artwork`,
values: formData,
});
},
});
};
const { mutate } = useCreate();
const onSave = () => {
mutate({
resource: "item",
values: {
...itemValues,
},
},
{
onSuccess: (data) => {
const id = data.data.id;
const formData = new FormData();
formData.append('file', artworks[0]);

Object.keys(artworkValues).forEach((k, i) => {
var d = Object.values(artworkValues)[i];
formData.append(k, d);
})

mutate({
resource: `item/${id}/artwork`,
values: formData,
});
},
});
};
<Create isLoading={formLoading} saveButtonProps={{ ...saveButtonProps, disabled: isSaveDisabled, onClick: onSave }}>
<Create isLoading={formLoading} saveButtonProps={{ ...saveButtonProps, disabled: isSaveDisabled, onClick: onSave }}>
This works, it created an item, then creates an artwork for us, no problem. However, we get the following error, which is caused by the artwork mutate, as when we comment it out the error doesn't happen.
mutation.ts:261 TypeError: Cannot read properties of undefined (reading 'onSettled')
at mutationObserver.ts:177:1
at Object.batch (notifyManager.ts:25:1)
at MutationObserver.notify (mutationObserver.ts:168:1)
at MutationObserver.onMutationUpdate (mutationObserver.ts:100:1)
at mutation.ts:356:1
at Array.forEach (<anonymous>)
at mutation.ts:355:1
at Object.batch (notifyManager.ts:25:1)
at Mutation.dispatch (mutation.ts:354:1)
at Mutation.execute (mutation.ts:248:1)
mutation.ts:261 TypeError: Cannot read properties of undefined (reading 'onSettled')
at mutationObserver.ts:177:1
at Object.batch (notifyManager.ts:25:1)
at MutationObserver.notify (mutationObserver.ts:168:1)
at MutationObserver.onMutationUpdate (mutationObserver.ts:100:1)
at mutation.ts:356:1
at Array.forEach (<anonymous>)
at mutation.ts:355:1
at Object.batch (notifyManager.ts:25:1)
at Mutation.dispatch (mutation.ts:354:1)
at Mutation.execute (mutation.ts:248:1)
Is there a better more refine way of doing what we are doing here?
6 replies
RRefine
Created by rare-sapphire on 3/15/2023 in #ask-any-question
Invalidate login when API authentication expires?
I'm trying to log a user out, and send them to the login page, if our API responds to say the session is invalid. As an example, a login session is invalidated if someone logs in with the same account on a different browser/device. Our API will start responding with a 401. I can get the 401 via an axios interceptor. How can I kick the "check" login functionality at this point, to then handle the redirect to login?
8 replies
RRefine
Created by extended-salmon on 3/15/2023 in #ask-any-question
Hidden input field?
No description
14 replies
RRefine
Created by gradual-turquoise on 3/15/2023 in #ask-any-question
Module '"@refinedev/react-hook-form"' has no exported member 'Controller'.
Hey, so I've copied out the code generated by MuiCreateInferencer for my edit page. For one of my fields, which is called isActive, it's generated the following code. import { useForm, Controller } from "@refinedev/react-hook-form"; <Controller control={control} name="isActive" // eslint-disable-next-line defaultValue={null as any} render={({ field }) => ( <FormControlLabel label="Is Active" control={ <Checkbox {...field} checked={field.value} onChange={(event) => { field.onChange(event.target.checked); }} /> } /> )} /> But Controller isn't in react-hook-form it seems? Using v4 FYI.
12 replies