Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing props to the ReactFilestack element does not work as expected #73

Open
juho opened this issue Sep 9, 2019 · 2 comments
Open
Assignees

Comments

@juho
Copy link

juho commented Sep 9, 2019

We're using rmwc components with material UI. This doesn't work as expected because of your tagMap:

import { Button } from 'rmwc'
<ReactFilestack
  componentDisplayMode={{
    type: Button
  }}
/>

As the ReactFilestack component only renders the button, optimally I would expect the API to be something like this..

import { Button } from 'rmwc'
<ReactFilestack
  component={Button}
  label='Upload a file'
  className='myclass'
/>

So, in your constructor, something like this:

    const {
      apikey,
      clientOptions,
      actionOptions,
      action,
      componentDisplayMode,
      // All other named props that you need
      ...rest
    } = this.props;

    this.componentProps = {...rest};

And in your render(), something like..

  render () {
    const Component = this.componentProps.component;
    return <Component name="filestack" onClick={this.onClickPick} {...this.componentProps} />
  }
@MowiliMi MowiliMi self-assigned this Jun 25, 2020
@MowiliMi
Copy link
Contributor

We don’t need add extra params, we can do that with customRender:

import "./App.css";

import ReactFilestack from "filestack-react";
import { Button } from "rmwc";
import "@material/button/dist/mdc.button.css";

function App() {
  return (
    <div className="App">
      <div id="inline"></div>
      <ReactFilestack
        customRender={({ onPick }) => (
          <Button label="Open picker" uneleted onClick={onPick} />
        )}
        apikey="your_api_key"
        actionOptions={{
          maxFiles: 10,
          imageMax: [3600, 3600],
          accept: ["image/jpeg"],
        }}
        onSuccess={(res) => console.log(res)}
      />
    </div>
  );
}

export default App;

@jakubpeksa
Copy link

Is it still happening in 4.0 version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants