You can use:
targets=($(grep -HRl "pattern" .))
Note use of (...) for array creation in BASH.
(...)
Also you can use grep -l to get only file names in grep's output (as shown in my command).
grep -l
grep