React-Client-Session TypeError: undefined is not an object (evaluating '_reactClientSession.default.setStoreType')

I am trying to use react-client-session :https://github.com/grizzthedj/react-session in a react native application. I am almost literally copying the example:

import ReactSession from 'react-client-session';

  <Button
                style = {styles.button}
                title="Submit"
                        onPress={() => {
                          ReactSession.setStoreType("localStorage");
                          ReactSession.set("playerName", selectedValue);
                             /* 1. Navigate to the Character Skill Sheet route with params */
                             navigation.navigate('SkillSheet', {
                              playerName: selectedValue
                            });
                        }}
                color="#19AC52"
            />

The expected result is that I press the button and along with navigating to the SkillSheet view it will set the session variable playerName = selectedValue.

But when I click the button I get this error: TypeError: undefined is not an object (evaluating '_reactClientSession.default.setStoreType')

Is react-client-session still in use? If so what am I doing wrong? Here is the other link to it: https://www.npmjs.com/package/react-client-session

This is the full file that I am trying to do this in:

CharacterSelectScreen.js

import React, {useState} from 'react'
import { StyleSheet, Text, View, TouchableOpacity, TextInput, Button, Picker, ScrollView} from 'react-native'
import { NavigationContainer, useNavigation, useRoute } from '@react-navigation/native';
import { userFetch } from '../../sharedComponents/userFetch.js';
import { styles } from './styles.js';
import ReactSession from 'react-client-session';

const CharacterSelectScreen = ({navigation, route}) => {
  const [characterList, setCharacterList] = useState([]);
  const [selectedValue, setSelectedValue] = useState("Choose..");

  //Using React.useEffect to simulate React's #componentDidMount
       React.useEffect(()=>{
        console.log('Select Screen loaded.')
        //Must use an async function to call the userFetch function then set the result equal to characterList
        const asyncFunc = async () => {
          const charList = await userFetch();
          setCharacterList(charList);
        }
        //Call the async function
        asyncFunc();
      },[])

    return (
        <View style={styles.container}>
            <Text style={{marginLeft: 130}} h1>Select a character:</Text>
            <Picker
              style={styles.charPicker}
              mode="dropdown"
              selectedValue={selectedValue}
              onValueChange={(itemValue, itemIndex) => setSelectedValue(itemValue)}
              >
              {characterList.map((item, index) => {
                  return (<Picker.Item label={item} value={item} key={index}/>) 
              })}
          </Picker>
          <Button
                style = {styles.button}
                title="Submit"
                        onPress={() => {
                          ReactSession.setStoreType("localStorage");
                          ReactSession.set("playerName", selectedValue);
                             /* 1. Navigate to the Character Skill Sheet route with params */
                             navigation.navigate('SkillSheet', {
                              playerName: selectedValue
                            });
                        }}
                color="#19AC52"
            />
      </View>
    )
}

export default CharacterSelectScreen;

And here is what is in my yarn.lock:

react-client-session@^0.0.7:
  version "0.0.7"
  resolved "https://registry.yarnpkg.com/react-client-session/-/react-client-session-0.0.7.tgz#b1bdee73d2dd29a0cd2ed220c91bd86671787dec"
  integrity sha512-UeiECmKybfqTp/Fk7qCOs0OV/Lnw3km5vNoYnVjygVDwqg8SPm8YzFKJcFsmNDhPh6Ak1oCjAySJfSDrSZglbQ==

80 thoughts on “React-Client-Session TypeError: undefined is not an object (evaluating '_reactClientSession.default.setStoreType')”

  1. of course like your web site but you need to check the spelling on quite a few
    of your posts. Many of them are rife with spelling problems and
    I to find it very bothersome to inform the truth nevertheless I
    will definitely come back again.

    Reply
  2. Good day! This is kind of off topic but I need some advice from an established blog.
    Is it very hard to set up your own blog?
    I’m not very techincal but I can figure things out
    pretty fast. I’m thinking about setting up my
    own but I’m not sure where to start. Do you have any tips or suggestions?
    Thank you

    Reply
  3. Somebody essentially lend a hand to make critically posts I’d state.
    This is the first time I frequented your website page and
    to this point? I surprised with the analysis
    you made to make this actual submit extraordinary. Wonderful job!

    Reply
  4. Fantastic goods from you, man. I have keep in mind your stuff previous to and you’re simply too fantastic.
    I actually like what you’ve got right here,
    certainly like what you’re saying and the way in which by which you are saying it.
    You make it enjoyable and you continue to take care of to stay it
    smart. I can’t wait to read much more from you.
    That is actually a great web site.

    Reply
  5. Excellent post. I used to be checking constantly this blog and I am impressed!
    Extremely useful information specially the closing section 🙂 I care for such information a
    lot. I was looking for this certain info for a long time.
    Thank you and good luck.

    Reply
  6. Greate article. Keep posting such kind of information on your page.
    Im really impressed by it.
    Hi there, You have done a great job. I will certainly digg
    it and in my opinion suggest to my friends. I’m sure they will be benefited from this website.

    Reply

Leave a Comment