First time I am very unsure about how to dealing with undefined object in Solidjs. Hopefully there is a better way to do this.
You may meet the undefined object when accessing a set of objects, like posts and pass to other components.
Undefined can be tackled using ?. as follows.
<Post post={post()?.post_type}/>
Here solid will check the post_type object which can be undefined for some point of time.
Similarly, we can also implement the login in template
{ props.post?.title[0].text || "Post title"}
- Prismic slices and Dynamic tag in Solidjs - Dynamic tag in Solidjs and Prismic Slice use case.
- Checking for undefined in Solidjs - How to deal with undefined in Solidjs
- Create contentful blog with Solidjs - How to build a minimal blog using Contentful CMS and Solidjs
- How to pass data to component from the router setup – solid-app-router - How to pass data from the router setup to the component in solid-app-router
- How to build a blog with Solidjs - How to create blog application using mocked graphql API and Solidjs front end framework
- How to handle Esc keystroke in Solidjs - How to handle Esc in Solidjs
- Create a mutable store in Solidjs - How to create a simple mutable store in Solidjs
- Setup Page Not Found route in Solidjs-app-router - How to setup a 404 route in Solidjs
- set focus using ref in Solidjs - How to set focus to an input in Solidjs using refs
- Create store in Solidjs - How to create store in Solidjs