Setting up Sanity with React project and resolving an error.
Last updated: Aug 7, 2021
Getting help with setting up project with Sanity and React:I created my React project in a folder using npm create-react-app portfolio. Where do I install Sanity? In the same folder? I tried this before and it just mixed the two things together and created a mess. Where should I enter: npm install -g @sanity/cli && sanity init ?
from the root folder of her project. When it prompts for “Project output path” the default should put your studio in a subfolder.
Aug 6, 2021, 11:06 PM
So I should install Sanity inside a sub-folder of the React project?
Aug 6, 2021, 11:21 PM
Yes, that’s one way to do it. Another is to install it outside the React project (i.e., as a sibling to the React folder). I think Kap does the former so that’s a good plan if you want to follow that tutorial.
Aug 6, 2021, 11:22 PM
So far so good! Will let you know how it turns out. THANK YOU!
Aug 7, 2021, 12:51 AM
Things went well until near the end when I got stuck here. I've gone through teh video twice and I' not sure what I am missing.
Aug 7, 2021, 6:24 AM
That error would happen if a post is missing a slug, since it’s looking for a property called
is undefined (i.e., doesn’t exist). There are a few ways to solve this, including short-circuiting (which Kap did a few lines above with