The difference is very slight but they are both correct depending on your context.
Here is what Oxford's Lexico says:
An acquired or natural skill at doing something.
‘he had a knack *for* communicating’
A tendency to do something.
‘John had the enviable knack *of* falling asleep anywhere’
October 10, 2019
Still haven’t found your answers?
Write down your questions and let the native speakers help you!