Skip to content

Commit

Permalink
Update documentation of how context is set
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-s committed Jul 31, 2021
1 parent 0da2507 commit 3a0e1e5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions docs/reflexes.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,17 @@ class ExampleReflex(Reflex):
def work(self):
# All new instance variables in the reflex will be accessible
# in the context during rendering.
self.instance_variable = 'hello world'
self.context.instance_variable = 'hello world'

context = self.get_context_data()
context['a_key'] = 'a pink elephant'

self.context.update(context)
# If "a_key" existed in the context before the reflex was triggered
# the context variable will now be modified to "a pink elephant"

# if it didn't exist, the context variable is then created with the
# data "a pink elephant" 🐘

```
{% endtab %}

Expand Down

0 comments on commit 3a0e1e5

Please sign in to comment.