React-redux-firebase: How to set dynamic value for firebaseConnect([{ path: value}])?

Created on 23 Oct 2018  路  1Comment  路  Source: prescottprue/react-redux-firebase

form upload.md

const filesPath was the default static value on the code top

i need filesPath can be changed so in my code filelsPath was setted by redux from

but in the recompose code style , that have a problem

like:

export const ImageUpload = compose(
    // Create listeners for Real Time Database which write to redux store
    firebaseConnect([{ path: filesPath }]),
    connect(state => {
        const path = selector(state, 'name')
        return {
            uploadedFiles: state.firebase.data[filesPath],
            filesPath: path
        }
    }),e
    setPropTypes(enhancerPropsTypes), // Set proptypes of props used within handlers
    withHandlers(handlers)
)(Component)

because filesPath was in the component firebaseConnect can`t be get it

so i just want to quest have any way to get value for firebaseConnect ?

Most helpful comment

You can provide a function that returns an array as the first argument instead of an array as shown in the query docs and the state based query snippet example.

// Pass filesPath prop as query path
firebaseConnect((props) => [{ path: props.filesPath }]),

Make sure you get the uploadedFiles object from the correct location of state afterwards.

>All comments

You can provide a function that returns an array as the first argument instead of an array as shown in the query docs and the state based query snippet example.

// Pass filesPath prop as query path
firebaseConnect((props) => [{ path: props.filesPath }]),

Make sure you get the uploadedFiles object from the correct location of state afterwards.

Was this page helpful?
0 / 5 - 0 ratings