uptick / react-keyed-file-browser

Folder based file browser given a flat keyed list of objects, powered by React.
MIT License
295 stars 143 forks source link

How to obtain currently selected files? #222

Closed noisersup closed 2 years ago

noisersup commented 2 years ago

I can see that it's placed in state variable selection and have tried to ref the state of RawFileBrowser but it's null.

import React, { useEffect,useState,useRef,}  from 'react'
import Moment from 'moment'

import '../../node_modules/react-keyed-file-browser/dist/react-keyed-file-browser.css';
import RawFileBrowser, {Icons} from 'react-keyed-file-browser'

export default function Files () {
  const [files, setFiles] = useState([]);
  const filebrowser = useRef();

  useEffect(() => {
      getFiles("")
      console.log(filebrowser.current.state)
  },[])

  return (
  <div className="filestorage">
  ...
    <RawFileBrowser
        ref={filebrowser}
        ...
    />
  </div>
  )
}
noisersup commented 2 years ago

Nevermind, the problem was that I imported RawFileBrowser outside curly brackets.