Using Formik as a peer dependency in a library #3079
Unanswered
iam-markus
asked this question in
Q&A
Replies: 1 comment 2 replies
-
That's definitely not going to work. It looks like you linked the development Formik into your project somehow. I'd guess that Formik is exposing an issue that you already have between your two projects. Installing Formik is causing your dependencies change that is causing your two projects to have different versions of React. You can test this by checking: > npm ls react
> npm ls react-dom
# example -- all deduped and same version
+-- @storybook/addon-actions@5.2.8
| +-- @storybook/api@5.2.8
| | `-- react@16.12.0 deduped
| +-- @storybook/components@5.2.8
| | `-- react@16.12.0 deduped
| `-- react@16.12.0 deduped
+-- @storybook/react@5.2.8
| `-- @storybook/core@5.2.8
| `-- @storybook/ui@5.2.8
| `-- react@16.12.0 deduped
`-- react@16.12.0 They should both return only one version from all dependencies. You can do a few things:
// package.json
{
// package.json things
resolutions: {
"react": "16.x.x" // the version of React you actually use
}
}
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello.
I have 2 projects:
A) A base library (npm package)
B) The main project
The base library contains components that need Formik, e.g:
However when importing Formik and using it in the Project, it throws this:
When I move the FormTextInput into the project, everythig works fine.
In the library I have declared Formik as a peer dependency (using parcel to bundle).
Because the library is linked (npm link) into the project, I tried linking formik but that throws an error as well:
Is there any workaround / solution how to include formik in npm libraries?
Beta Was this translation helpful? Give feedback.
All reactions