ayoub_owl
ayoub_owl
TTCTheo's Typesafe Cult
Created by celtic426 on 5/22/2024 in #questions
Can you store refs in an object in React?
I think what you can do is this
const refs = useRef({
contextChildrenActive: null,
primaryNavBar: null,
...
});

return (
<div className="App">
<div ref={(ref) => (ref.current.contextChildrenActive = ref)} type="text" />
<div ref={(ref) => (ref.current.primaryNavBar = ref)} type="text" />
</div>
);
const refs = useRef({
contextChildrenActive: null,
primaryNavBar: null,
...
});

return (
<div className="App">
<div ref={(ref) => (ref.current.contextChildrenActive = ref)} type="text" />
<div ref={(ref) => (ref.current.primaryNavBar = ref)} type="text" />
</div>
);
you could even use an array
3 replies
TTCTheo's Typesafe Cult
Created by ayoub_owl on 1/11/2023 in #questions
react table v7 with typescript
Solved
function EditableCell<T extends object>({
value: initialValue,
row: { index },
column: { id },
updateData,
}: CellProps<T, any>) {
const [value, setValue] = React.useState(initialValue);

const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setValue(e.target.value);
};

// We'll only update the external data when the input is blurred
const onBlur = () => {
updateData(index, id, value);
};

// If the initialValue is changed external, sync it up with our state
React.useEffect(() => {
setValue(initialValue);
}, [initialValue]);

return (
<input
value={value}
onChange={(event) => onChange(event)}
onBlur={onBlur}
/>
);
}
function EditableCell<T extends object>({
value: initialValue,
row: { index },
column: { id },
updateData,
}: CellProps<T, any>) {
const [value, setValue] = React.useState(initialValue);

const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setValue(e.target.value);
};

// We'll only update the external data when the input is blurred
const onBlur = () => {
updateData(index, id, value);
};

// If the initialValue is changed external, sync it up with our state
React.useEffect(() => {
setValue(initialValue);
}, [initialValue]);

return (
<input
value={value}
onChange={(event) => onChange(event)}
onBlur={onBlur}
/>
);
}
2 replies
TTCTheo's Typesafe Cult
Created by ayoub_owl on 12/31/2022 in #questions
Next auth session cookie is not set after successful login
unless there is a reason that I don't know
20 replies
TTCTheo's Typesafe Cult
Created by ayoub_owl on 12/31/2022 in #questions
Next auth session cookie is not set after successful login
so in my opinion it's just an annoying limitation
20 replies
TTCTheo's Typesafe Cult
Created by ayoub_owl on 12/31/2022 in #questions
Next auth session cookie is not set after successful login
but with session it's not
20 replies
TTCTheo's Typesafe Cult
Created by ayoub_owl on 12/31/2022 in #questions
Next auth session cookie is not set after successful login
with jwt it works fine
20 replies
TTCTheo's Typesafe Cult
Created by ayoub_owl on 12/31/2022 in #questions
Next auth session cookie is not set after successful login
I'm sorry that's not my question, bc in the example I showed I store the password in the database
20 replies
TTCTheo's Typesafe Cult
Created by ayoub_owl on 12/31/2022 in #questions
Next auth session cookie is not set after successful login
doesn't make since to me
20 replies
TTCTheo's Typesafe Cult
Created by ayoub_owl on 12/31/2022 in #questions
Next auth session cookie is not set after successful login
how using jwt is preventing me from storing the password in the database?
20 replies
TTCTheo's Typesafe Cult
Created by ayoub_owl on 12/31/2022 in #questions
Next auth session cookie is not set after successful login
Good point actually, sorry for misunderstanding your intentions, but the answers in the docs wasn't satisfying, that's why I put the a question here
20 replies
TTCTheo's Typesafe Cult
Created by ayoub_owl on 12/31/2022 in #questions
Next auth session cookie is not set after successful login
Is that also in the docs?
20 replies
TTCTheo's Typesafe Cult
Created by ayoub_owl on 12/31/2022 in #questions
Next auth session cookie is not set after successful login
I also wonder why you're an Ahole
20 replies
TTCTheo's Typesafe Cult
Created by ayoub_owl on 12/31/2022 in #questions
Next auth session cookie is not set after successful login
I wonder why they don't allow it with credentials!
20 replies
TTCTheo's Typesafe Cult
Created by ayoub_owl on 12/31/2022 in #questions
Next auth session cookie is not set after successful login
Ok I'll try it, thanks
20 replies