Frontity tutorial: Switch not defined

I’m working my way through the frontity tutorial. I’m fairly new to modern js frontend development.

I’m working through this tutorial page:

Specifically I’m working with this snippet of code:
https://gist.github.com/bobdobbs/25c68ab7a7405b4f49fb5a0d2de503e4

This results in the error:
Uncaught (in promise) ReferenceError: Switch is not defined

That makes sense: I haven’t seen ‘Switch’ before, so I imagine it’s a component defined somewhere within the frontity framework.

If I google it I find it documented here:
https://api.frontity.org/frontity-packages/collections-packages/components

So I’ve added this line to the snippet:
import Switch from "@frontity/components/switch";

Once this line is added, I get the outcome I want. The project compiles without a browser error.

This could be a stumbling block for people at around my level. I suggest that the documentation be updated with a little more detail. I suggest at least adding this line to the example code. Beyond that I suggest adding a little detail to the tutorial about the frontity components.

Thanks.

1 Like