Pregunta

I'm not sure if I'm missing something here but when I console.log my attributes I am getting an empty object. Shouldn't it show the default data of all my attributes. What I am doing wrong here.

import { __ } from '@wordpress/i18n';
import { registerBlockType } from '@wordpress/blocks';
import { useEffect } from '@wordpress/blocks';
import { PluginDocumentSettingPanel } from '@wordpress/edit-post';
import GoogleMap from './GoogleMap.js';
import { Component } from '@wordpress/element';
import axios from 'axios';

registerBlockType( 'splash-blocks/google-maps', { 
    title: __('Google maps locations', 'google-maps'),
    icon: 'megaphone',
    category: 'common',
    keyword: [
        __( 'Display Google maps locations' ),
    ],
    atrributes: {
        markers: {
            type: 'array',
            default: [{
                lat: 37.79406,
                lng: -122.4002,
            }],
        },
        icon: {

        },
    address: {
        type: 'string',
        default: 'xxxxxxxxx',
        }, 
        api_key: {
        type: 'string',
        default: 'xxxxxxxxx',
        }
    },
    edit({ attributes, setAttributes }) {

        console.log(attributes)
        //Console shows empty object
        return ( 
            <div id='google-map'>
            </div>
        )
    },
    save: null,
})
¿Fue útil?

Solución

Your block has no attributes. It does however have atrributes.

Change atrributes to attributes and things should make more sense.

Licenciado bajo: CC-BY-SA con atribución
scroll top