posting a preprint will generally not affect the publication of the same paper in a journal. Most journals, including Nature Portfolio journals and PLOS, allow posting of preprints prior to submission for peer review, and will not consider preprints as prior publication. It is important to note that some journals may have their own policies regarding preprints, so it is always a good idea to check with the specific journal before submitting your work. Additionally, some journals may prioritize the publication of work that has not yet been disseminated widely, so posting a preprint may potentially affect the priority of publication.
you can have a look at below mentioned articles, for having a better understanding of Pre-prints.
What are the drawbacks of pre-print?
"Disadvantages:
Not peer reviewed (submission only undergoes minimal checking e.g. grammar)
Not all formats are accepted (e.g. editorials, book reviews)
Some journals (not all) do not accept articles previously posted as a preprint .Authors need to be very careful not to jeopardise where they ultimately wish to publish their article by publishing the preprint.
Once published on a preprint server an article cannot generally be withdrawn"