Any way to make functions use variables from the place it was imported to? [duplicate]

I’m trying not to repeat code and have a complicated function that’s used in at least 3 different components in react. I’m trying to put them all in one folder and importing them but there’s a ton of dependencies that I pass as function parameters and even after I’ve done that, I can’t figure out how to pass setState as a parameter because it keeps telling me it’s not a function.

export const doThing = (setState) => {
    code
}
import { doThing } from "./place"

doThing(setState)
TypeError: setState is not a function

Even if I can get setState working I still feel like there should be a better way. Really I’d just like it to act like a copy paste and use variables from the scope it was imported to. Any way to do that?