Giter VIP home page Giter VIP logo

Comments (11)

yefriddavid avatar yefriddavid commented on July 19, 2024 9

For me works!

this

manualPrint() {

this.printRef.handlePrint();

}

render(){
<ReactToPrint
ref={el => (this.printRef = el)}
trigger={() => Imprimir}
content={() => this.componentRef}
/>

......

from react-to-print.

MatthewHerbst avatar MatthewHerbst commented on July 19, 2024

Do you mean without using the React component at all? Right now you can do:

render() {
  componentDidMount() {
    this.ref.handlePrint();
  }

  return (
        <ReactToPrint
          ...
          ref={ref => this.ref = ref}
        />
  );
}

I'd be interested in moving the print API outside of the component itself. How do you imagine setting up target in your example?

from react-to-print.

leeseean avatar leeseean commented on July 19, 2024

Do you mean without using the React component at all? Right now you can do:

render() {
  componentDidMount() {
    this.ref.handlePrint();
  }

  return (
        <ReactToPrint
          ...
          ref={ref => this.ref = ref}
        />
  );
}

I'd be interested in moving the print API outside of the component itself. How do you imagine setting up target in your example?

target is a ref or domNode

from react-to-print.

mengbimao avatar mengbimao commented on July 19, 2024

东西是好东西,但是貌似我这个项目用不了,我照着上面来做了,但是样式貌似没有打印出来,无论怎么说还是辛苦啦,点一个星,不成敬意

from react-to-print.

mengbimao avatar mengbimao commented on July 19, 2024

image
image
image

from react-to-print.

Eli-Black-Work avatar Eli-Black-Work commented on July 19, 2024

Thanks for the info :) It would be great if this were documented, though.

Also, any chance of making the trigger() function optional? :)

from react-to-print.

heyjaypray avatar heyjaypray commented on July 19, 2024

I'm currently having a similar issue. I'm currently using material-table and would like to have a button that you click that will print the info contained passed into a component.

Screen Shot 2019-08-10 at 2 02 30 PM

My code looks like this -

constructor(props) {
    super(props);

    this.state = {
      orderLoaded: false,
      orderData: []
    };
    this.printRef = React.createRef();

  }
onClick: (event, rowData) => {
    this.setState({ orderData: rowData })
    this.setState ({ orderLoaded: true })
    this.printRef.handlePrint();
}

Then i have

{this.state.orderLoaded ? 
  <div>
    <ReactToPrint
       ref={el => (this.printRef = el)}
       trigger={this.state.orderLoaded = true}
       content={() => this.componentRef}
     />
     <AssemblyList
       selectedOrder={this.state.orderData}
       ref={el => (this.componentRef = el)} />
   </div>
        : 
  <div />
} 

i'm getting an error that says

Uncaught TypeError: _this2.printRef.handlePrint is not a function
and
Uncaught TypeError: e is not a function

any ideas?

from react-to-print.

MatthewHerbst avatar MatthewHerbst commented on July 19, 2024

@heyjaypray we don't have a feature available yet where you can call that method directly. Something I've been meaning to work on. I'll also happily accept any PRs :)

from react-to-print.

MatthewHerbst avatar MatthewHerbst commented on July 19, 2024

We have had the ability to useReactToPrint for some time now 😄

from react-to-print.

Hamza-Wakrim avatar Hamza-Wakrim commented on July 19, 2024

did you found solution for #68 (comment)?
cause i have same problem

from react-to-print.

Eli-Black-Work avatar Eli-Black-Work commented on July 19, 2024

@Hamza-Wakrim I think you should be using the useReactToPrint() function 🙂

from react-to-print.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.