Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter varun286

    (@varun286)

    Hi @nerrad Thank you. It works.

    Thread Starter varun286

    (@varun286)

    Hi @nerrad
    Thanks for the reply.

    I have added some hooks(filters/actions) and I need to hook into these from different plugin.

    I am able to add filter for applied filters within same plugin js file but not working when added from different plugin.

    Here is code from main plugin –

    import React from 'react';
    import { Component } from '@wordpress/element';
    import { applyFilters } from '@wordpress/hooks';
    import { addFilter } from '@wordpress/hooks';
    import { useFilters } from '@woocommerce/components';
    
    export const TEST_FILTER = 'wk_test_filter';
    
    // addFilter( TEST_FILTER, 'plugin-domain', title => {
    //  return <code>Added to ${title}</code>;
    // } );
    
    export const titleFilter = applyFilters( TEST_FILTER, 'Default text' );
    
    class App extends Component {
        constructor( props ) {
            super( props );
        }
    
        render() {
            return (
                <div>
                    <h1>{ titleFilter }</h1>
                </div>
            );
        }
    }
    
    export default useFilters( TEST_FILTER )(App);

    The commented code in above snippet is working fine but when I add the same filter from different react based plugin then it is not working anymore.

    Regards

Viewing 2 replies - 1 through 2 (of 2 total)