Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the ways to access $c from JavaScript #2806

Merged
merged 1 commit into from
Jan 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,13 +482,9 @@ Common instructions for porting:
```

3. You can access most of the [Catalyst Context](http://search.cpan.org/~ether/Catalyst-Manual-5.9009/lib/Catalyst/Manual/Intro.pod#Context) in JavaScript
via the variable `$c`. This is passed as a prop automatically if the
component is top-level or used from `React.embed`. If you need to access
`$c` from a deeply-nested component, you can either pass it down from
a parent component, or import the `CatalystContext`
[React context](https://reactjs.org/docs/context.html) from
root/context.mjs and either use the `CatalystContext.Consumer` component
or use `React.useContext(CatalystContext)`.
by importing the `CatalystContext` [React context](https://reactjs.org/docs/context.html)
from root/context.mjs and either using the `CatalystContext.Consumer` component
or using `React.useContext(CatalystContext)` (assigned by convention to the constant `$c`).

4. To communicate between the Perl and Node servers (the latter renders React
components for us), you need to appropriately serialize the props passed
Expand Down