Setting Default Inject/Provide Values in Vueby@smpnjn
1,280 reads

Setting Default Inject/Provide Values in Vue

August 1st 2022
2m
by @smpnjn 1,280 reads
tldt arrow
Read on Terminal Reader
Read this story w/o Javascript

Too Long; Didn't Read

Vue uses provide and inject as a method to send data down multiple levels without having to use **properties** - but did you know you can set default values for any injected data, should it not be injected in the first place? Let's look at how it works. By default, `inject` expects a default value to be set for a `provide` key - and if it's not, it'll throw a runtime error. As such, it's beneficial to set a default. value so that a runtime. error does not fire.
featured image - Setting Default Inject/Provide Values in Vue
Johnny Simpson HackerNoon profile picture

@smpnjn

Johnny Simpson

Product, Engineering, Web


Receive Stories from @smpnjn

react to story with heart

RELATED STORIES

L O A D I N G
. . . comments & more!