Combine rhandsontable and fileInput in Shiny

Hi,

I'm trying to combine fileInput and rhandsontable functions in Shiny app.

In the following example you can see the problem I have. If I create the data frame (df) manually, the app runs well and each time I change the values of the table (df), the plot change and show new values. I would like to do the same but using data that I load by fileInput function. The commented part is what I have tried without success.

shinyUI(navbarPage("ExampleApplication",fluid = TRUE,
         tabPanel('A',

         sidebarLayout(
             sidebarPanel(
                fileInput('file', 'Upload your data'),
             ),
             mainPanel(
                 rHandsontableOutput('table'),
                 plotOutput("distPlot")
             ))
         ),
          tabPanel('B',
                       #add here code from page B
               )
))


shinyServer(function(input, output) {

           # df_input <- reactive({
           #     if(is.null(input$fileInput)){return()}
           #     datos <- read.csv2(input$fileInput$datapath, stringsAsFactors = FALSE)
           #     return(datos)
           # })
           # 
           # df <- df_input()

           df <- data.frame(a = c(1,2,3), b = c(7,6,4))

           datavalues <- reactiveValues(data = df)

           output$table <- renderRHandsontable({
                 rhandsontable(datavalues$data)
           })

          observeEvent(
                  input$table$changes$changes,
                  {
                         datavalues$data <- hot_to_r(input$table)
                   }
           )

           output$distPlot <- renderPlot({
                      ggplot(datavalues$data, aes(x = a, y = b)) + geom_point()
           })
})

And this is the error message "Error in .getReactiveEnvironment()$currentContext(): Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)"

I would greatly appreciate any contribution or help