Nativebase: TypeError: Cannot read property '_root' of undefined

Created on 5 Jul 2017  路  3Comments  路  Source: GeekyAnts/NativeBase

I get this error oftentimes when I try to submit a redux form and show a success toast.

react-native, react and native-base version

react-native: 0.45.1
react: 16.0.0-alpha.12
native-base: 2.2.0

Expected behaviour

I expect a green toast message to show up briefly when the form submission is successful.

Actual behaviour

The form submits, but no toast message is displayed and this error shows in the console.

Steps to reproduce (code snippet or screenshot)

_onSubmitJobType = jobTypeId => {
  const { jobId, showErrors, jobJobTypeSelect, } = this.props

  return jobJobTypeSelect({
    addProcesses: true,
    jobId,
    jobTypeId,
  })
    .then(() => {
      Toast.show({
        text: "Changed job type successfully!",
        position: "bottom",
        buttonText: "Okay",
        type: "success",
        duration: TOAST_VISIBLE_TIME,
      })
    })
    .catch(error => {
      devLog('_onSubmit error', error)
      showErrors()
    })
}

Screenshot of emulator/device

screen shot 2017-07-05 at 3 21 19 pm

Is the bug present in both ios and android or in any one of them?

Only tested on ios.

Any other additional info which would help us debug the issue quicker.

This has been happening for a while now on earlier versions as well. I also made a stack overflow question about it earlier.

Most helpful comment

Is your main app component wrapped in <Root>? I ran into this issue the other day and that solved it for me. See the docs: https://docs.nativebase.io/Components.html#Toast

All 3 comments

Exactly same problem here, with same versions but on Android...

Is your main app component wrapped in <Root>? I ran into this issue the other day and that solved it for me. See the docs: https://docs.nativebase.io/Components.html#Toast

Thanks @amhinson! That worked!

Was this page helpful?
0 / 5 - 0 ratings