const pairs = { a: 'ა', b: 'ბ', g: 'გ'};
const str = 'There are many ways that reading helps you to learn English.';
[...str].map(letter => pairs[letter.toLowerCase()] || letter).join``;
const pairs = { a: 'ა', b: 'ბ', g: 'გ'};
const str = 'There are many ways that reading helps you to learn English.';
str.replace(RegExp(Object.keys(pairs).join('|'), 'gi'), letter => pairs[letter.toLowerCase()]);
const API = process.env.api;
module.exports = {
...,
plugins: [
...,
new webpack.DefinePlugin({
API_URL: JSON.stringify(API)
})
]
}
{
"scripts": {
"build": "webpack --env.api=https://api.url/v1"
}
}
npm run build -- --env.api=https://api.url/v2
it(`handle action ${patientActions.ON_CHANGE_PATIENT}`, ()=>{
expect(reducer(undefined, {
type: patientActions.PATIENT_INIT_STATE, // тут должно быть patientActions.ON_CHANGE_PATIENT
payload: {
value: '11122',
field: 'patient_ur'
}
})).toEqual({...defaultStates, patient_ur: '11122'})
})
export default function reducer(state=initialState, action) {
switch (action.type) {
case 'INCRE_TEST':
return state.int + action.int
default:
return state
}
}
И тут самое непонятное, как все это правильно собирать?
Не понимаю как подключить функцию к onClick
const mapDispatchToProps = dispatch => {
return {
onClick: int => {
dispatch(increTest(int))
}
}
}
const mapDispatchToProps = dispatch => {
return {
onClick: () => {
dispatch(increTest(1))
}
}
}
<button onClick={() => this.props.onClick(1)}>Click onClick</button>
( (int)27923 )
function getAttachmentsPost($post_id = 0) {
$args = array(
'post_parent' => $post_id,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'posts_per_page' => -1,
);
if ( $attachments = get_children( $args ) ) {
return $attachments;
}
return [];
}
wp_localize_script( 'img_import', 'MyAjax', array(
'ajaxurl' => admin_url('admin-ajax.php'),
'nonce' => wp_create_nonce('myajax-nonce'),
'pluginsUrl' => plugins_url()
) );
wp_localize_script( 'img_import.js', 'MyAjax', array(
'ajaxurl' => admin_url('admin-ajax.php'),
'nonce' => wp_create_nonce('myajax-nonce'),
'pluginsUrl' => plugins_url()
) );