change the line
import { Joi } from "joi-browser";
to
import Joi from "joi-browser";
and that should solve the error.
Answer from codeMe on Stack OverflowI already posted this on RPG maker forums but might as well post it here, while its waiting for approval.
I have this part in my game, where the positioning of characters switches around after a cutscene. I do this using the "Save Event Position" plugin by Shaz. Since today after the cutscene, this error message started popping up.
Disabeling the plugin fixes it, it's essential to the gameplay though. I've compared it with a backed up version from 4 days ago (my backed up version from yestarday has the same issue) where the problem doesn't occur. I compared the event, that triggers the plugin with the old version and haven't found any differences. As I have no knowledge of JS I'm pretty stumped.
Does anyone have any ideas? Many thanks in advance!
Changing this if condition from this:
if (props.items.length === 0) {
To
if (!props.items?.length) {
Should work.
Similarly if using for places,you can check using ternary operator if length exists in array of places.
How? Because items could possibly be null or undefined from apis, so the length property on array might be missing.
Moreover, using ! Not operator would make this condition true if length of items is 0 or is null or undefined or any falsy value
The other answers are focusing on prop.items list but in your question you mention that you get the exception when trying to access the length of the places inside users.
You are getting the error message because some users may not have any places listed inside them, hence, no places list -> no length property.
To fix this, you need to check if the places list exists and then access its length:
placeCount={ user.places ? user.places.length : 0 }
Here, we use a ternary operator to check if user.places exists, then we use the length, else use zero.
Edit: As pointed out by Phil in the comments below, you can also use coalescing operator, which is much cleaner, like this:
placeCount={ user.places?.length ?? 0 }
The syntax simply translates as if user.places has a value for length, then use that value, else use zero as a default value.
use !post || !post.length or !posts?.length
The error says the type of posts is Undefined. As you are getting that value from Posts in state object, that means that Posts is not initialized in your state.
Try initializing "Posts" with empty Array([]) in your initial state object.