What is the correct way to update attributes using...
# ask-questions
c
What is the correct way to update attributes using
@growthbook/growthbook-react
here in docs https://docs.growthbook.io/lib/react#updating-attributes
Copy code
gb.setAttributes({
  // Only update the `url` attribute, keep the rest the same
  ...gb.getAttributes(),
  url: "/new-page"
})
but I found that there is a method:
Copy code
gb.updateAttributes()
it spreads previous attributes under the hood. But it doesn't cover in docs. So probably it can be removed in next versions of SDK. What will your recommendation?
s
Both will work the same way, but I'd use
updateAttributes
as it makes it clearer what's happening. I'll also update the docs to reflect this method.
❤️ 1
c
Thank you for your response!
😀 1